【发布时间】:2012-02-17 18:18:05
【问题描述】:
我有一个这样写的 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"}
];
我要做的是获取每个 ID。
我一直在尝试这个
for(x in json[0]){
alert(x.id);
}
但是运气不好,有人能指出我正确的方向吗?请和谢谢你:)
【问题讨论】:
-
您可能会发现阅读
for...indocumentation 也很有帮助。
标签: javascript arrays for-loop