<! DOCTYPE html>
<meta charset= "Utf-8" >
<title></title>
<script src= "Jquery-1.8.3.js" ></script>
<body>
<button> Select All </button>
<button> not selected </button>
<button> Anti-selection </button>
<div id= "Main" >
<input type= "checkbox" > Basketball
<br>
<input type= "checkbox" > Badminton
<br>
<input type= "checkbox" > Table Tennis
<br>
<input type= "checkbox" > Soccer
<br>
<input type= "checkbox" > Rugby
<br>
<input type= "checkbox" > Baseball
</div>
</body>
<script type= "Text/javascript" >
Select All
$ (' button '). EQ (0). Click (function () {
$ (' input '). attr (' checked ', true);
});
All do not choose
$ (' button '). EQ (1). Click (function () {
$ (' input '). attr (' checked ', false);
});
Inverse selection
$ (' button '). EQ (2). Click (function () {
$ (' input '). each (function () {
this.checked=!this.checked;
});
});
</script>
Use jquery for all, all, uncheck, and reverse (button)