您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> 编程语言综合 >> 正文

jquery实现全选、反选

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 

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="">