<! DOCTYPE html>
<title>jquery check box Practice </title>
<!--introduce jquery to your own jquery file--
<script type= "Text/javascript" src= ". /scripts/jquery-1.7.2.js "></script>
<body>
<div>
<p> Select the fruit you want to buy </p>
<ul class= "Fruit" >
<li><input type= "checkbox" value= "001"/> Apple </li>
<li><input type= "checkbox" value= "002"/> Sydney </li>
<li><input type= "checkbox" value= "003"/> Mango </li>
<li><input type= "checkbox" value= "004"/> Pineapple </li>
</ul> <input type= "checkbox" id= "All"/> <button id= "Checkall" > select all </button> <button id= " Nothing ">
Select all </button> <button id= "Reverseall" > Reverse selection </button> <button class= "choosefruit" > Purchase </button >
<script type= "Text/javascript" >
<!--Select All/All-
$ ("#All"). Click (function () {if ("this.checked") {
$ ("#fruit: CheckBox"). Prop ("checked", true);
}else{
$ ("#fruit: CheckBox"). Prop ("checked", false);
}
});
<!--Select All-
$ ("#checkAll"). Click (function () {$ ("#fruit: CheckBox"). Prop ("checked", true);});
<!--all without--
$ ("#nothing"). Click (function () {$ ("#fruit: CheckBox"). Prop ("checked", false);});
<!--Reversed--$ ("#reverseAll"). Click (function () {$ ("#fruit: CheckBox"). each (function (i) {
$ (this). Prop ("Checked",
!$ (This). Prop ("checked"));
});
});
<!--get the value of the check box selected--$ (". Choosefruit"). Click (function () {
var arr = new Array ();
$ ("#fruit: checkbox[checked]"). each (function (i) {
Arr[i] = $ (this). Val ();
});
var vals = Arr.join (",");
Console.log (Vals); });
</script>
</div>
</body>
jquery cheched Select All/Select All