0
我只是在另一个看到张贴的解决方案,但是当我尝试在我的代码中使用它,它不工作。克隆antoher
我试图通过按钮在一个表上添加项目到另一个。任何帮助表示赞赏。如预期
HTML
<div id="container">
<input type="text" name="search" id="search" placeholder="Ingrese el nombre del examen..." size="50">
</input>
<table id="proctable" >
<tr>
<th>Examen</th>
<th>Precio</th>
<th></th>
</tr>
<tr>
<td>hola</td>
<td>10</td>
<td><input class="addBtn" type="button" value="Agregar"></td>
</tr>
</table>
<hr>
<div>
<table id="comptable">
<tr class="header">
<th>Examen</th>
<th>Precio</th>
</tr>
</table>
</div>
</div>
JS
<script type="text/javascript">
var items = [];
$(".addBtn").on("click", function() {
var newTr = $(this).closest("tr").clone();
items.push(newTr);
newTr.appendTo($("#comptable"));
});
</script>
https://jsfiddle.net/45nfvg9j/
你好,感谢你。我从javascript中打开和关闭标签,代码仍然无法使用。 –
如果您也修复了问题#2,则代码有效。查看jsFiddle中的html - 无效的输入标记以红色突出显示! –
固定他们两个,还是有同样的问题 –