Table本身就有个复制的属性。
解决方案 »
- ExtJS问题求助
- 刚学javascript,问一个比较弱智的问题
- 寻求js仿xp资源管理器全部代码(100)
- javascript怎么获得php中变量的值?
- 关闭ModalDialog窗口出错,怎么改?
- 把鼠标锁定到屏幕的某一个位置。
- 用JavaScript连接数据库的问题,在线等待
- 請問可不可以只刷新jsp頁面的某一部分,例如頁面中的某一個表格,而不是整個頁面都刷新,可不可以實現的,如何做?因爲現在要做一個聊天
- 按提交按钮的时候,可以播放一段音乐吗?用JS可以吗....
- 一般输出的:)和TEXTAREA的:)不同,为什么?
- 输入非法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>