我原来做过现成的例子,这议会找不着源代码。但给你提供思路。很简单,
鼠标点击某行,将其存入一个变量,然后,拷贝的实现 就用 obj=TrID.cloneNode(true);
粘贴实现: obj.replaceNode(Tr2ID);TrID 就是选中的行,Tr2ID 待粘贴的行。自己做一个,很简单。我来帮你写个例子
鼠标点击某行,将其存入一个变量,然后,拷贝的实现 就用 obj=TrID.cloneNode(true);
粘贴实现: obj.replaceNode(Tr2ID);TrID 就是选中的行,Tr2ID 待粘贴的行。自己做一个,很简单。我来帮你写个例子
<head>
<title>无标题文档</title>
<script language=javascript>
function copy_row(){
obj=row1.cloneNode(true);
obj.replaceNode(row2);
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<table width="75%" border="1">
<tr id=row1>
<td>aaaa</td>
<td>bbbb</td>
<td>cccc</td>
</tr>
<tr id=row2>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table><input type="button" name="test" value="复制行" onclick="javascript:copy_row()">
</form>
</body>
</html>
<COL STYLE="color:red" id=col1 >
<COL STYLE="color:blue" id=col2>
<COL STYLE="color:green" id=col3>
<TR onmouseover="this.style.backgroundColor='#cceedd'" onmouseout="this.style.backgroundColor=''">
<TD onclick="col1.style.color=(col1.style.color=='red')?'orange':'red'" onmouseover="this.style.cursor='hand'">点击这里</TD>
<TD onclick="col2.style.color=(col2.style.color=='blue')?'orange':'blue'" onmouseover="this.style.cursor='hand'">点击这里</TD>
<TD onclick="col3.style.color=(col3.style.color=='green')?'orange':'green'" onmouseover="this.style.cursor='hand'">点击这里</TD>
</TR>
<TR onmouseover="this.style.backgroundColor='#ccddff'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR>
<TR onmouseover="this.style.backgroundColor='#dddddd'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR>
<TR onmouseover="this.style.backgroundColor='#eeeeee'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR> <TR onmouseover="this.style.backgroundColor='#cceedd'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR> <TR onmouseover="this.style.backgroundColor='#cceedd'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR> <TR onmouseover="this.style.backgroundColor='#cceedd'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</TR> <TR onmouseover="this.style.backgroundColor='#cfcfcf'" onmouseout="this.style.backgroundColor=''">
<TD>此列位于第一组。</TD>
<TD>此列位于第二组。</TD>
<TD>此列位于第三组。</TD>
</tr>
</TABLE><button id="btn1" onclick="tbl.lastChild.appendChild(tbl.rows(tbl.rows.length-1).cloneNode(true));
">添加行</button><button id="btn2">添加列</button>
">添加行</button>
<script language=javascript>
function copy_row(){
obj=row1.cloneNode(true);
row2.replaceNode(obj);
}
</script>