我有一個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