哪错了,找了好久还看不出来,求解释!
哪错了,找了好久还看不出来,求解释!
2015-04-16
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script> <title>挑战题</title>
</head>
<body>
<span><input id="btn" type="button" value="检索"/></span>
<span><ul>学生信息:</ul></span>
//错误:1.json格式不对 ,2.json中有两个逗号不是英文状态的,3.打印json数据的时候没设定对应的变量(即each中function的第二个参数)
<script type="text/javascript">
var $stuJson = [
{"name":"张三","age":"34"},
{"name":"李四","age":"28"},
{"name":"王五","age":"25"}
];
$(function($){
$("#btn").bind("click",function(){
$.each($stuJson,function(index,st){
$("ul").append("<li>"+
"姓名:"+st["name"]+
"年龄:"+st["age"]+"</li>");
});
});
})
</script>
</body>
</html>
举报