<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="http://libs.baidu.com/jquery/1.8.2/jquery.js" type="text/javascript"></script> <title>挑战题</title> </head> <body> <input type="button" value="show infor" id="button"/> <ul id="infor"></ul> <script type="text/javascript"> var myJson=[{"name":"zhang3","age":"27"},{"name":"li4", "age":"30"}]; $("#button").click(function(){ $.each(myJson,function(index,value){ $("#infor").append("<li>name: "+ value.name +" age: "+ value.age +"</li>"); }) } ) </script> </body> </html>
老哥看看你myJson之间的那个逗号是对的吗 应该是英文的,
细节要注意