JQ achieves select all and not select

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title>全选与全不选</title>
 6         <script type="text/javascript" src="../js/jquery-1.11.0.js"></script>
 7         <script>
 8             $(function(){
 9                 $("#checkbox1").click(function(){
10                     $(":checkbox:gt(0)").prop("checked",this.checked);
11                 });
12             });
13         </script>
14     </head>
15     <body>
16         <table>
17             <tr>
18                 <td><input type="checkbox" name="checkbox1" id="checkbox1" onclick="selectAll()"></td>
19             </tr>
20             <tr>
21                 <td><input type="checkbox" name="checkbox1"></td>
22             </tr>
23             <tr>
24                 <td><input type="checkbox" name="checkbox1"></td>
25             </tr>
26             <tr>
27                 <td><input type="checkbox" name="checkbox1"></td>
28             </tr>
29             <tr>
30                 <td><input type="checkbox" name="checkbox1"></td>
31             </tr>
32         </table>
33     </body>
34 </html>

 

Guess you like

Origin www.cnblogs.com/yxfyg/p/12672677.html