萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> jquery實現全選、反選

jquery實現全選、反選

 

1 <script src="js/plugin/jquery-1.9.0.js"></script>

 

 

 

 

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 $(document).ready(function() {     $("#selectAll").click(function() {         $("input[name='subBox']").each(function() {             this.checked = true;         });     });     $("#reverse").click(function() {         $("input[name='subBox']").each(function() {             if (this.checked) {                 this.checked = false;             } else {                 this.checked = true;             }         });      });     $("#checkItems").click(function() {         $("input[name='subBox']").each(function() {             if (this.checked) {                 this.checked = false;             } else {                 this.checked = true;             }         });     }); });

 

? 1 2 3 <input type="checkbox" id="checkItems">                        全選                 反選

 

? 1 2 <input type="checkbox" name="subBox" value="">

 

copyright © 萬盛學電腦網 all rights reserved