我目前在學習JavaScript的開始階段,想知道你怎麼能遍歷這個數組和輸出的所有數據作爲HTML內容:的Javascript環路(初級)
var links = new Array(); //Missing this part as code
links[0] = new Array();
links[0]["linkName"] = "W3Schools";
links[0]["linkLogo"] = "http://www.w3schools.com/images/w3schools.png";
links[0]["linkURL"] = "http://www.w3schools.com/";
links[0]["linkDescription"] = "W3Schools is a web developer information website, with tutorials and references relating to web development topics such as HTML, CSS, JavaScript and PHP.";
links[1] = new Array();
links[1]["linkName"] = "Code Academy";
links[1]["linkLogo"] = "";
links[1]["linkURL"] = "https://www.codecademy.com/";
links[1]["linkDescription"] = "Codecademy is an online interactive platform that offers free coding classes in 9 different programming languages.";
links[2] = new Array();
links[2]["linkName"] = "";
links[2]["linkLogo"] = "http://www.w3.org/2008/site/images/logo-w3c-mobile-lg";
links[2]["linkURL"] = "http://www.w3.org/";
links[2]["linkDescription"] = "The World Wide Web Consortium is the main international standards organization for the World Wide Web.";
「將所有數據輸出爲html內容」確實含糊不清。此外,在提出SO問題之前,嘗試使用Google搜索並顯示您嘗試過的內容。人們會很樂意幫助你。 – jmargolisvt
這是一個相當奇怪的數據結構,讓每個數組項都包含具有屬性的對象會不會更容易? (我不確定'links [0] [「linkName」] =「W3Schools」;'會做你認爲它會的) – DBS
人們低估你是迂腐笨蛋,因爲你沒有定義'html'和'output 」。代表他們接受我的道歉。大多數人都很棒,整個社區也是如此!給.forEach一個谷歌,在JS中循環,也許一般的JS教程!你可能已經潛入深度,所以採取緩慢,並繼續編碼:)一切順利! –