javascript动态增加表格行,在行的text框中用jquery选择输入项无效 我的那些师傅说prototype jquery 专门摧残 js的 Array 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <head> <link charset="utf-8" rel="stylesheet" type="text/css" href="jquery.popup.css"/><script type="text/javascript" charset="utf-8" src="jquery.js"> </script><script type="text/javascript" charset="utf-8" src="jquery.dimensions.js"> </script><script type="text/javascript" charset="utf-8" src="jquery.popup.js"> </script></head><script type="text/javascript">jQuery(function($){ $("input.popup").popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); $("#ding").focus(function(){ //只知道有个focus,不知道focusout是什么东西 $("#hztable").append('<input id="dganwei' + (++i) + '" type="text" class="popup" value="1" />'); $("#dganwei" + i).popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); //$("input.popup").popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); });});var i = 2;</script><body><div id="hztable"> <input id="danwei1" type="text" class="popup" value="1" /> <input id="danwei2" type="text" class="popup" /> <br/> <input type="text" /></div><table width="10%" border=1 align="center" cellpadding="0" cellspacing="0" id="mxtable" ><tr align="center"><td>name <input id="ding" name="ding" type="text" maxlength="10" /> </td></tr></table></body></html> 你那个错误是函数addNew有问题用DIV比表格简单很多既然都用到jQ了为什么不尽量用jQ来做呢没有测试,你自己测试一下<html><head><link charset="utf-8" rel="stylesheet" type="text/css" href="jquery.popup.css"/><script type="text/javascript" charset="utf-8" src="jquery.js"> </script><script type="text/javascript" charset="utf-8" src="jquery.dimensions.js"> </script><script type="text/javascript" charset="utf-8" src="jquery.popup.js"> </script></head><script type="text/javascript">jQuery(function($){ $("input.popup").popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); $("#ding").focus(function(){ //只知道有个focus,不知道focusout是什么东西 $("#hztable").append(' <input id="dganwei' + (++i) + '" type="text" class="popup" value="1" />'); $("#dganwei" + i).popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); //$("input.popup").popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); });});var i = 2;</script><body><div id="hztable"> <input id="danwei1" type="text" class="popup" value="1" /> <input id="danwei2" type="text" class="popup" /> <br/> <input type="text" /></div><table width="10%" border=1 align="center" cellpadding="0" cellspacing="0" id="mxtable" ><tr align="center"><td>name <input id="ding" name="ding" type="text" maxlength="10" /> </td></tr></table></body></html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script src="http://www.cnjquery.com/demo/jquery.js"></script><style type="text/css">body{background:#FFFFFF;}</style></head><body><script>$(document).ready(function(){ var show_count = 20; //要显示的条数 var count = $("input:text").val(); //递增的开始值,这里是你的ID var fin_count = parseInt(count) + (show_count-1); //结束递增的条件 $("input:button").click( function() { if(count < fin_count) //点击时候,如果当前的数字小于递增结束的条件 { $("tr:eq(1)").clone().appendTo("table"); //在表格后面添加一行 $("tr:last td input:first").val(++count); //改变添加的行的ID值。 } } );});</script><input type="button" value="添加一行" /><table width="700" border="0" cellspacing="0" cellpadding="0" id="addtr"> <tr> <td height="30" align="center" bgcolor="#CCCCCC">ID</td> <td align="center" bgcolor="#CCCCCC">Username</td> <td align="center" bgcolor="#CCCCCC">Usertype</td> <td align="center" bgcolor="#CCCCCC">Other</td> </tr> <tr> <td height="30" align="center"><input type="text" size="2" value="1" /></td> <td align="center"><input type="text" name="username" /></td> <td align="center"> <select name="type"> <option value="1">Administrator</option> <option value="2">Guest</option> </select> </td> <td align="center"><input type="text" name="username2" /></td> </tr></table></body></html> 添加音乐到播放列表 document.write 或者div的问题 163邮箱添加文件夹或者删除邮件时的那个浮动窗口时怎样实现的呢? TextBox显示日期和时间!! 高手帮忙 想用js生成客户端的文件目录树 表格用了table-layout: fixed后单元格能自动扩充 如何捕获窗口大小改变的事件? 请问我的下拉框的内容比下拉框还要宽,我想要在点击按钮时完整显示内容,怎么办?没有分了,对不起 怎样使左右的框架网页每次都按高度大的网页显示?急用! 如何写.js文件?求教! 说下您对这段代码的理解 如何实现点击页面A上的按钮,控制Div层B的显示
<link charset="utf-8" rel="stylesheet" type="text/css" href="jquery.popup.css"/>
<script type="text/javascript" charset="utf-8" src="jquery.js"> </script>
<script type="text/javascript" charset="utf-8" src="jquery.dimensions.js"> </script>
<script type="text/javascript" charset="utf-8" src="jquery.popup.js"> </script>
</head><script type="text/javascript">
jQuery(function($){
$("input.popup").popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); $("#ding").focus(function(){
//只知道有个focus,不知道focusout是什么东西
$("#hztable").append('<input id="dganwei' + (++i) + '" type="text" class="popup" value="1" />');
$("#dganwei" + i).popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>');
//$("input.popup").popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>');
});
});
var i = 2;
</script><body>
<div id="hztable">
<input id="danwei1" type="text" class="popup" value="1" />
<input id="danwei2" type="text" class="popup" />
<br/>
<input type="text" />
</div><table width="10%" border=1 align="center" cellpadding="0" cellspacing="0" id="mxtable" >
<tr align="center">
<td>name <input id="ding" name="ding" type="text" maxlength="10" /> </td>
</tr>
</table></body>
</html>
用DIV比表格简单很多
既然都用到jQ了为什么不尽量用jQ来做呢
没有测试,你自己测试一下<html>
<head>
<link charset="utf-8" rel="stylesheet" type="text/css" href="jquery.popup.css"/>
<script type="text/javascript" charset="utf-8" src="jquery.js"> </script>
<script type="text/javascript" charset="utf-8" src="jquery.dimensions.js"> </script>
<script type="text/javascript" charset="utf-8" src="jquery.popup.js"> </script>
</head><script type="text/javascript">
jQuery(function($){
$("input.popup").popup('<a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>'); $("#ding").focus(function(){
//只知道有个focus,不知道focusout是什么东西
$("#hztable").append(' <input id="dganwei' + (++i) + '" type="text" class="popup" value="1" />');
$("#dganwei" + i).popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>');
//$("input.popup").popup(' <a href="#">demo1Text </a> <br /> <a href="#">demo2Text </a>');
});
});
var i = 2;
</script><body>
<div id="hztable">
<input id="danwei1" type="text" class="popup" value="1" />
<input id="danwei2" type="text" class="popup" />
<br/>
<input type="text" />
</div><table width="10%" border=1 align="center" cellpadding="0" cellspacing="0" id="mxtable" >
<tr align="center">
<td>name <input id="ding" name="ding" type="text" maxlength="10" /> </td>
</tr>
</table></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://www.cnjquery.com/demo/jquery.js"></script>
<style type="text/css">
body{background:#FFFFFF;}
</style>
</head>
<body>
<script>
$(document).ready(
function()
{
var show_count = 20; //要显示的条数
var count = $("input:text").val(); //递增的开始值,这里是你的ID
var fin_count = parseInt(count) + (show_count-1); //结束递增的条件
$("input:button").click(
function()
{
if(count < fin_count) //点击时候,如果当前的数字小于递增结束的条件
{
$("tr:eq(1)").clone().appendTo("table"); //在表格后面添加一行
$("tr:last td input:first").val(++count); //改变添加的行的ID值。
}
}
);
}
);</script>
<input type="button" value="添加一行" />
<table width="700" border="0" cellspacing="0" cellpadding="0" id="addtr">
<tr>
<td height="30" align="center" bgcolor="#CCCCCC">ID</td>
<td align="center" bgcolor="#CCCCCC">Username</td>
<td align="center" bgcolor="#CCCCCC">Usertype</td>
<td align="center" bgcolor="#CCCCCC">Other</td>
</tr>
<tr>
<td height="30" align="center"><input type="text" size="2" value="1" /></td>
<td align="center"><input type="text" name="username" /></td>
<td align="center">
<select name="type">
<option value="1">Administrator</option>
<option value="2">Guest</option>
</select>
</td>
<td align="center"><input type="text" name="username2" /></td>
</tr>
</table>
</body>
</html>