我在我的页面上创建了两个表格。我希望当用户点击一个表格行时,该行的数据被复制到另一个表格。使用javascript将行从一个表复制到另一个表
<div class="processor">
<table id="proctable">
<tr class="header">
<th>Description</th>
<th>Price</th>
</tr>
<tr class="hover">
<td><span id="4770K"><a href="#">Intel Core i7 4770K 4TH GEN. 3.5GHZ 8MB CACHE MAX TURBO FREQUENCY 3.9GHZ</a></span></td>
<td>$320</td>
</tr>
<tr class="hover">
<td><span id="4771"><a href="#">Intel Core i7 4771 4TH GEN. 3.5GHZ 8MB CACHE MAX TURBO FREQUENCY 3.9GHZ</a></span></td>
<td>$290</td>
</tr>
<tr class="hover">
<td><span id="4770"><a href="#">Intel Core i7 4770 4TH GEN. 3.4GHZ 8MB CACHE MAX TURBO FREQUENCY 3.9GHZ</a></span></td>
<td>$280</td>
</tr>
<tr class="hover">
<td><span id="4771"><a href="#">Intel Core i5 4670K 4TH GEN. 3.4GHZ 6MB CACHE MAX TURBO FREQUENCY 3.8GHZ</a></span></td>
<td>$240</td>
</tr>
</table>
<div id="aside">
<table id="comptable">
<tr class="header">
<th>Product</th>
<th>Price</th>
</tr>
</table>
</div>
我已经寻找任何帮助我可以找到,但不能得到任何具体的答案
。
这里是链接到代码上的jsfiddle http://jsfiddle.net/jibranjb/LzgNd/#&togetherjs=fcgCI5QRn8
我是相当新的JavaScript和jQuery,所以请考虑这一点。
谢谢!
你能否解释一下这个问题吗?你什么时候需要复制?如果你只是想复制这个将会工作$(“#proctable tr”)。clone()。appendTo($(“#comptable”)) –
检查http://jsfiddle.net/4qFgX/1/演示 –
实际上我正在一个网页上工作,我需要显示点击项目的详细信息。 detail div包含一个ADD TO LIST按钮。点击该按钮后,需要将该项目添加到其他表格中。 – jibranjb