HTML:
<h3>对象数组显示</h3> <table id="obj" border="1"> </table>
jquery:
var animals = [ { 'name':'dog', 'mouse':'wangwang..' }, { 'name':'cat', 'mouse':'miaomiao..' }, { 'name':'pig', 'mouse':'nene...' }, { 'name':'bird', 'mouse':'jiji..' }, ]; $.each(animals, function(index,value){ $('table#obj').append('<tr><td>'+value.name+'</td><td>'+value.mouse+'</td></tr>'); });
运行结果:
知识点:
1,json