json.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>创建一个json格式数组,数组中有三个对象</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript">
var ps = [
{
id:1,
name:'哈哈'
},
{
id:2,
name:'呵呵'
},
{
id:3,
name:'嘻嘻'
}
];
</script>
<script type="text/javascript">
document.write("共有" + ps.length + "个学生<br/>");
for(var i=0;i<ps.length;i++){
document.write("编号:" + ps[i].id + "<br/>");
document.write("姓名:" + ps[i].name + "<br/>");
}
</script>
</body>
</html>
网友评论