(003)复选框全选

 1 <html>
 2     <head>
 3         <meta http-equiv="content-Type" content="text/html;charset=utf-8">
 4         <script type="text/javascript">
 5             window.onload = function() {
 6                 var btn = document.getElementById("btn");
 7                 var inputNodeArr = document.getElementsByTagName("input");
 8                 
 9 
10                 btn.onclick = function() {
11                     //inputNodeArr[0].checked = true;
12                     for(var i = 0; i < inputNodeArr.length; i++)
13                     {
14                         inputNodeArr[i].checked = true;
15                     }
16                 };
17             }
18         </script>
19     </head>
20     <body>
21         <p id="btn">全选</p>
22         <input type="checkbox"/> <br/>
23         <input type="checkbox"/> <br/>
24         <input type="checkbox"/> <br/>
25         <input type="checkbox"/> <br/>
26         <input type="checkbox"/> <br/>
27         <input type="checkbox"/> <br/>
28     </body>
29 </html>

 

posted @ 2013-11-25 22:08  雪中飞雁  阅读(58)  评论(0)    收藏  举报