问候,
我有一个输入数量可变的表单,其简化版本如下所示:
<form>
<label for="same">all the same as first?</label>
<input id="same" name="same" type="checkbox" />
<input type="text" id="foo[1]" name="foo[1]" value="" />
<input type="text" id="foo[2]" name="foo[2]" value="" />
<input type="text" id="foo[3]" name="foo[3]" value="" />
<input type="text" id="foo[4]" name="foo[4]" value="" />
<input type="text" id="foo[5]" name="foo[5]" value="" />
</form>
想法是勾选#same 复选框并让jQuery 将#foo[1] 中的值复制到#foo[2]、#foo[3] 等。如果未选中#same,它们还需要清除。
根据表单前一阶段的输入,可以有任意数量的#foo 输入,这给我带来了麻烦。我确定我遗漏了一些明显的东西,但我无法在$('#dest').val($('#source').val());
工作中得到任何变化。
帮助!