3
.change克隆適用於第一個字段,但不適用於第二個字段。我可以添加到我的循環?JQuery - 第一個文本字段上的克隆表.change事件
謝謝。
<table>
<tr>
<td><input type="text" id="txtA" name="txtA"></td>
<td><input type="text" id="txtB" name="txtB"></td>
</tr>
</table>
<script>
var i = 1;
$("#txtA").change(function() {
$("table tr:first").clone().find("input").each(function() {
$(this).val('').attr('id', function(_, id) { return id + i });
}).end().appendTo("table");
i++;
});
</script>
什麼你的意思是「作品」?據我所知,它不會爲第二個文本字段做任何事情,因爲您只將`.change()`綁定到`$(「#txtA」)`。 – Blazemonger 2011-12-15 19:31:33
對。如何將更改事件綁定到每個連續的txtA2,txtA3等。? – user1100603 2011-12-15 19:33:21