alert(“Age:”+person.Age+”Name:”+person.Name) });
});
</script>
</head>
<body>
</body>
</html>
客户端通过$.parseJSON()将后台传递过来的字符串转化为js数组对象,接下来我们就使用操作普通数组的方式来操作这个得到的数组
第三种就是通过标签选择器获取的Jquery对象数组,
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title></title>
<script src=”../myjs/jquery-1.4.2.js” type=”text/javascript”></script>
<script type =”text/javascript” >
$(function() {
$(“p”).text(“这是p标签”);
});
</script>
</head>
<body>
<p></p>
<p></p> <p></p> <p></p> <p></p>
<p></p>
</body>
</html>
在浏览器中运行的效果为:

在dom加载完成后为每一个p元素动态的添加了文本,首先$(“p”)获取p标签的集合,相当于Javascript中的document.getElementByTagName只是这里得到的是Jquery对象的数组,这样就有了Jquery固有的隐式迭代的功能,后面的text(“这是p标签”)的操作就迭代到了每一个P标签上,我们也可以显示的调用each函数来显示的迭代获得的Jquery对象数组,下面的代码同样可以实现上面的效果:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title></title>
<script src=”../myjs/jquery-1.4.2.js” type=”text/javascript”></script>
<script type =”text/javascript” >
$(function() {
$(“p”).each(function() {
$(this).text(“这是p标签”);
});
});
</script>
</head>
<body>
<p></p>
<p></p> <p></p> <p></p> <p></p>
<p></p>
</body>
</html>










