正文
for循环:
1 <script> 2 var obj = { 3 "status":1, 4 "bkmsg":"\u6210\u529f", 5 "bkdata":["\u5415\u5c1a\u5fd7","1387580400","\u6dfb\u52a0\u8bb0\u5f55"] 6 } (obj.status == 1) { 9 for (var i = 0; i < obj.bkdata.length; i++) { 10 console.log(obj.bkdata[i]); 11 }; 12 }else{ 13 alert("数据有误~"); 14 }; 15 </script>for in 循环:
1 <script> 2 var obj = { 3 "status":1, 4 "bkmsg":"\u6210\u529f", 5 "bkdata":["\u5415\u5c1a\u5fd7","1387580400","\u6dfb\u52a0\u8bb0\u5f55"] 6 } (x in obj.bkdata){ console.log(obj.bkdata[x]); 11 } 12 </script>元素 each方法
1 <script> 2 var obj = { 3 "status":1, 4 "bkmsg":"\u6210\u529f", 5 "bkdata":["\u5415\u5c1a\u5fd7","1387580400","\u6dfb\u52a0\u8bb0\u5f55"] 6 } (obj.status == 1) { 9 $(obj.bkdata).each(function(index,item){ console.log(item); }); 17 }else{ 18 alert("数据有误~"); 19 }; 20 </script>jquery each方法
1 <script> 2 var obj = { 3 "status":1, 4 "bkmsg":"\u6210\u529f", 5 "bkdata":["\u5415\u5c1a\u5fd7","1387580400","\u6dfb\u52a0\u8bb0\u5f55"] 6 } 7 8 $.each( obj.bkdata, function(index,item){ 9 console.log(item); 10 }); 11 </script>