js如何拷贝table! Table本身就有个复制的属性。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.scriptlover.com/post/389 直接复制table的outerHTml,整个table代码都出来了~~想多少拷贝就多少 <!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=gb2312" /> <title>test</title> <script>function f(count) { for (var i = 0; i < count; i ++) { document.body.insertAdjacentHTML("beforeEnd", document.getElementsByName("table1")[0].outerHTML); }}</script></head> <body> <table id="table1" width="100" border="1"> <tr> <td><input type="checkbox" />1</td> </tr> <tr> <td><select><option>1</option></select></td> </tr> <tr> <td><input type="button" value="button" /></td> </tr></table><br /><input id=count type="text" style="width:20px" /><input type="button" value="复制" onclick="f(count.value)" /><br /><br /></body> </html> 你的table 的id需要改动么? cloneNode<table style="background-color:#eee;margin:10px" id="tbl" border="1" ><tr><td><input type="text" value="aaaa"/></td><td><input type="text" value="bbbb"/></td></tr><tr><td><select><option>1</option></select></td><td><select><option>1</option></select></td></tr></table><div id="copyArea"></div>拷贝次数:<input type="text" id="tNum" value="5"/><br><input type="button" value="Copy(include of data)" onclick="copyTbl()"/><script>function copyTbl(){ var n = document.getElementById("tNum").value; var tbl = document.getElementById("tbl"); var div = document.getElementById("copyArea"); if(/^\d+$/.test(n)) { for(var i=0;i<n;i++) { var cTbl=tbl.cloneNode(true) div.appendChild(cTbl); } }}</script> 那我就简洁一点:<script language="javascript">function copy(){ for(var T=table1,i=eval(T1.value);(--i)>=0;) T.insertAdjacentElement('AfterEnd',T.cloneNode(true));}</script><table id="table1">...............</table>copy个数:<input type="text" id="T1" value="5"><input type="button" value="copy" onclick="copy()"> <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title> <script type="text/javascript"> function funCopy() { //行数 这里就不做验证了 var count=document.getElementById("txtCount").value * 1; //取得tr列表 var trlist=document.getElementById("table1").getElementsByTagName("tr"); //清空table2表 var t2=document.getElementById("table2"); while(t2.hasChildNodes()) { t2.removeChild(t2.firstChild); } //给table2表增加数据. var temp; for(var i=0;i<count;i++) { temp=trlist[i].cloneNode(true); t2.appendChild(temp); } } </script></head><body> <input id="txtCount" type="text" value="3" /> <input id="btnCopy" onclick="funCopy();" type="button" value="button" /> <table> <tbody id="table1"> <tr> <td>11</td> <td>111</td> </tr> <tr> <td>22</td> <td>222</td> </tr> <tr> <td>33</td> <td>333</td> </tr> <tr> <td>44</td> <td>444</td> </tr> </tbody> </table> <table> <tbody id="table2"> </tbody> </table></body></html> javascript遇到的问题 【散分】解决jQuery 1.4 json问题 检测是否安装了播放器 尽量减少服务器开销的前提下js动态获取服务器时间! js中怎么能令下条语句延时5秒钟执行??急!!!!!!!!!!! javascript实现图片随鼠标滚动而上下移动效果! 如何检查radio类型的是否已经填了数? 请问如何使循环放慢速度了???? 求:Balloon对象的classid。 程序更新的问题!!!很奇怪的事!!!急!那位仁兄帮帮小女子吧!!!!!!!:`( 输入非法html,禁止FCKeditor将其自动删除的办法。 怎么向iframe中注册click事件
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<script>
function f(count) {
for (var i = 0; i < count; i ++) {
document.body.insertAdjacentHTML("beforeEnd", document.getElementsByName("table1")[0].outerHTML);
}
}
</script>
</head>
<body>
<table id="table1" width="100" border="1">
<tr>
<td><input type="checkbox" />1</td>
</tr>
<tr>
<td><select><option>1</option></select></td>
</tr>
<tr>
<td><input type="button" value="button" /></td>
</tr>
</table><br />
<input id=count type="text" style="width:20px" />
<input type="button" value="复制" onclick="f(count.value)" /><br /><br />
</body>
</html>
<table style="background-color:#eee;margin:10px" id="tbl" border="1" >
<tr>
<td><input type="text" value="aaaa"/></td>
<td><input type="text" value="bbbb"/></td>
</tr>
<tr>
<td><select><option>1</option></select></td>
<td><select><option>1</option></select></td>
</tr>
</table>
<div id="copyArea">
</div>
拷贝次数:<input type="text" id="tNum" value="5"/><br>
<input type="button" value="Copy(include of data)" onclick="copyTbl()"/>
<script>
function copyTbl()
{
var n = document.getElementById("tNum").value;
var tbl = document.getElementById("tbl");
var div = document.getElementById("copyArea");
if(/^\d+$/.test(n))
{
for(var i=0;i<n;i++)
{
var cTbl=tbl.cloneNode(true)
div.appendChild(cTbl);
}
}
}
</script>
function copy(){
for(var T=table1,i=eval(T1.value);(--i)>=0;)
T.insertAdjacentElement('AfterEnd',T.cloneNode(true));
}
</script><table id="table1">...............</table>
copy个数:<input type="text" id="T1" value="5">
<input type="button" value="copy" onclick="copy()">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function funCopy()
{
//行数 这里就不做验证了
var count=document.getElementById("txtCount").value * 1;
//取得tr列表
var trlist=document.getElementById("table1").getElementsByTagName("tr");
//清空table2表
var t2=document.getElementById("table2");
while(t2.hasChildNodes())
{
t2.removeChild(t2.firstChild);
}
//给table2表增加数据.
var temp;
for(var i=0;i<count;i++)
{
temp=trlist[i].cloneNode(true);
t2.appendChild(temp);
}
}
</script>
</head>
<body>
<input id="txtCount" type="text" value="3" />
<input id="btnCopy" onclick="funCopy();" type="button" value="button" />
<table>
<tbody id="table1">
<tr>
<td>11</td>
<td>111</td>
</tr>
<tr>
<td>22</td>
<td>222</td>
</tr>
<tr>
<td>33</td>
<td>333</td>
</tr>
<tr>
<td>44</td>
<td>444</td>
</tr>
</tbody>
</table>
<table>
<tbody id="table2">
</tbody>
</table>
</body>
</html>