$.each遍历json对象

二维数组如下代码显示,如果一维数组的话,则,idx表示index,而obj直接就是值value而不是object对象。

 

var json = [
    {"id":"1","tagName":"apple"},
    {"id":"2","tagName":"orange"},
    {"id":"3","tagName":"banana"},
    {"id":"4","tagName":"watermelon"},
    {"id":"5","tagName":"pineapple"}
];
 
$.each(json, function(idx, obj) {
    alert(obj.tagName);
});

 

posted @ 2017-04-19 15:05  jerryhe326  阅读(412)  评论(0编辑  收藏  举报