我有一个fiddle如何在克隆的输入对象的值内打印嵌套数组?
代码:
//create array with values
thisArray= ['',[]];
thisArray[0] = ['numbers',['one','two','three','four','five']];
// have a clean clone of input
var newElem = $('#input').clone();
//search through aray and print the nested array inside the
// value of the cloned input
for(i = 0; i<thisArray[0][1].length; i++){
$(newElem).val(thisArray[0][1][i]);
$('input.input').last().after(newElem);
}
条件:我不能改变所述阵列的HTML或布局。
问题:如何编辑for循环在克隆的输入字段中一个接一个地显示数组中的数字?所以最终的输出将是六个输入字段,每个输入字段除第一个输入字段外都有一个数字。
您能否确认我的理解正确?你想克隆一个ID为#input的输入,并在页面上的类“.input”的最后一个输入之后插入该输入。你想在那个克隆的输入中显示“一个”,“两个”等,并且你希望在数字之间有一点点延迟,比如“one”....“two”....“three” 。主要是 – Niko 2012-03-13 01:08:05
,我想要6个输入字段,每个字段除了第一个输入字段。我改变了小提琴,所以不会有超过一个元素具有相同的'身份证' – 2012-03-13 01:11:17