如题
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7 <title>Jquery_属性操作</title>
8 <meta name="author" content="Administrator" />
9 <script type="text/javascript" src="jquery-1.11.1.js"></script>
10 <script type="text/javascript">
11
12 $(function(){
13 //属性名
14 var props = ["num","name","class","grade"];
15 var objs = new Array();
16
17 $("tbody tr").each(function(){
18 var obj = new Object();
19 $(this).find("td").each(function(n){
20 obj[props[n]] = $(this).html();
21 });
22 objs.push(obj);
23 });
24
25 for(var i=0;i<objs.length;i++){
26 alert(objs[i]["num"] + " -- " + objs[i]["name"] + " -- " + objs[i]["class"] + " -- " + objs[i]["grade"]);
27 }
28
29 });
30
31 </script>
32 <!-- Date: 2014-11-23 -->
33 </head>
34 <body>
35 <table width="500px" height="300px" cellpadding="0px" cellspacing="0px" border="1px solid black">
36 <thead>
37 <tr><th>编号</th><th>姓名</th><th>班级</th><th>年级</th></tr>
38 </thead>
39 <tbody>
40 <tr><td>01</td><td>duyt111</td><td>01class</td><td>01grade</td></tr>
41 <tr><td>02</td><td>duyt222</td><td>02class</td><td>02grade</td></tr>
42 <tr><td>03</td><td>duyt333</td><td>03class</td><td>03grade</td></tr>
43 <tr><td>04</td><td>duyt444</td><td>04class</td><td>04grade</td></tr>
44 <tr><td>05</td><td>duyt555</td><td>05class</td><td>05grade</td></tr>
45 <tr><td>06</td><td>duyt666</td><td>06class</td><td>06grade</td></tr>
46 </tbody>
47 </table>
48 </body>
49 </html>
50