var people = { "programmers":[ { "firstName": "Brett", "lastName":"McLaughlin", "email": "aaaa"},
{ "firstName": "Jason", "lastName":"Hunter", "email": "bbbb" },
{ "firstName": "Elliotte", "lastName":"Harold", "email": "cccc" }],
"authors":[ { "firstName": "Isaac", "lastName": "Asimov", "email": "science fiction" },
{ "firstName": "Tad", "lastName": "Williams", "email": "fantasy" },
{ "firstName": "Frank", "lastName": "Peretti", "email": "christian fiction" }],
"musicians":[ { "firstName": "Eric", "lastName": "Clapton", "email": "guitar" },
{ "firstName": "Sergei", "lastName": "Rachmaninoff", "email": "piano" },
{ "firstName": "Ranen", "lastName": "Tong", "email": "Ranen" }]
}只需遍历显示9个firstName的值就行,
$("#btnEachJson").click(function(){
$.each(people,function(index,value){
$.each(value,function(index2,value2){
//只能进来3次,何解?必须用jQuery
});
});
});
$.each(people,function(index,value){
$.each(value,function(index2,value2){
alert(value2.firstName);
});
});你这样不就都拿出来了吗 ?