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 - 無效的輸入標記以紅色突出顯示! –
固定他們兩個,還是有同樣的問題 –