我寫這樣的JavaScript數組...的Javascript循環數組
var json = [
{"id":"1", "title":"Test 1", "comment":"This is the first test"},
{"id":"2", "title":"Test 2", "comment":"This is the second test"}
];
什麼,我試圖做的是讓IDS中的每一個。
我一直在嘗試這種
for(x in json[0]){
alert(x.id);
}
,但沒有運氣,有人可以點我在正確的方向?請和謝謝你:)
[與字符串數組輸出索引迴路...](可能重複http://stackoverflow.com/questions/ 7480020/for-in-loop-with-string-array-outputs-indices) – 2012-02-17 18:21:58
您可能會發現閱讀['for ... in'文檔](https://developer.mozilla.org/ EN/JavaScript的/參考/語句/對...的)。 – 2012-02-17 18:22:38