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