0
對,所以我有一系列的類div,我想不出如何在每一個輸出一個條目。將數據分成類框
<a class='foo'></a>
<a class='foo'></a>
<a class='foo'></a>
bar = document.getElementsByClassName('foo');
arr ['cheese','soap','glove'];
for(i=0;i<bar.length;i++) {
bar[x].appendChild(document.createTextNode(arr[i]));
}
此輸入cheesesoapglove到每個類的div中...我如何在陣列中的每個字符串分離出來進入一個DIV盒子一樣的下面:
<a class='foo'>cheese</a>
<a class='foo'>soap</a>
<a class='foo'>glove</a>
如果你是誰upvoted我的回答的一個,謝謝!同時,如果您認爲它回答了您的問題,您可能希望將其作爲正確的答案(投票按鈕下方的大號複選標記),再次感謝! – webeno
此外,或者正在查看此頁面的用戶,您將遇到以下問題:輸出將始終是if語句的最終產品。 http://www.mennovanslooten.nl/blog/post/62 – Ewan