jquery遍历html所有对象

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>jquery</title>
 6 <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
 7 <script type="text/javascript">
 8 $(function(){
 9     $("body *").each(function(){
10         alert($(this).html());
11     });
12 });
13 </script>
14 </head>
15 
16 <body>
17 <div class="a1">Node 1</div>
18 <div>Node 2</div>
19 <div class="a2">Node 3</div>
20 <div>Node 4</div>
21 <div>Node 5</div>
22 <div>Node 6</div>
23 <div>
24 Node 7
25 <div>Child node</div>
26 </div>
27 </body>
28 </html>

 

posted on 2010-11-12 00:49  暮光青年  阅读(804)  评论(0编辑  收藏  举报

导航