我有以下的javascript設置瓦爾使用循環
information0 = xmlDoc.getElementsByTagName("info")[0].textContent;
information1 = xmlDoc.getElementsByTagName("info")[1].textContent;
information2 = xmlDoc.getElementsByTagName("info")[2].textContent;
information3 = xmlDoc.getElementsByTagName("info")[3].textContent;
information4 = xmlDoc.getElementsByTagName("info")[4].textContent;
information5 = xmlDoc.getElementsByTagName("info")[5].textContent;
information6 = xmlDoc.getElementsByTagName("info")[6].textContent;
我要創建每個索引編號的新變種。總共有600個。我如何使用for循環來做到這一點?
在此先感謝
爲什麼不把它放在數組中 –
你可以使用'Array' - 'information = [];信息[0] = xmlDoc ...; ...' –
好的,所以我已經看到你所有的答案,但我需要給他們打電話,像這樣 'document.write(information0 +「
」); document.write(information1 +「
」); document.write(information2 +「
」); document.write(information3 +「
」); document.write(information4 +「
」); document.write(information5 +「
」); document.write(information6 +「
」);' – craig