Method One
$ ("#myform"). Togglecheckboxes ()//All selected, deselect all, reverse
$ ("#myform"). Togglecheckboxes (": Not (#checkbox1)")/select all, deselect all and uncheck the first
$ ("#myform"). Togglecheckboxes (". Top5", True)/Select all, deselect all and select only the first five, reverse
$ ("#myform"). Checkcheckboxes ()/Select All
$ ("#myform"). Checkcheckboxes (": Not (#checkbox1)");//Select All except the first
$ ("#myform"). Checkcheckboxes (". Top5", true);//Top Five Select all
$ ("#myform"). Uncheckcheckboxes (); Deselect Select All
$ ("#myform"). Uncheckcheckboxes (": Not (#checkbox1)");//deselect all, exclude the first
$ ("#myform"). Uncheckcheckboxes (". Top5", true);//deselect all excluded top five
Method Two
<script language= Web page special effects src= "Jquery.js" ></script>
<script language= "JavaScript" >
<!--
$ ("document"). Ready (function () {
$ ("#all"). Click (function () {
if (this.checked) {
$ ("Input[name= ' checkbox ']"). each (function () {this.checked=true;});
$ ("#btn1"). attr ("value", "reverse election");
}else{
$ ("Input[name= ' checkbox ']"). each (function () {this.checked=false;});
$ ("#btn1"). attr ("Value", "Select All");
}
});
$ ("#btn1"). Click (function () {
$ ("[name= ' checkbox ']"). attr ("Checked", ' true ');/select All
})
$ ("#btn2"). Click (function () {
$ ("[name= ' checkbox ']"). Removeattr ("checked");/Cancel All selection
})
$ ("#btn3"). Click (function () {
$ ("[name= ' checkbox ']:even"). attr ("Checked", ' true ');//Select All odd numbers
})
$ ("#btn4"). Click (function () {
$ ("[name= ' checkbox ']"). each (function () {
if ($ (this). attr ("checked"))
{
$ (this). Removeattr ("checked");
}
Else
{
$ (this). attr ("Checked", ' true ');
}
})
})
$ ("#btn5"). Click (function () {
var str= "";
$ ("[name= ' checkbox '][checked]"). each (function () {
str+=$ (This). Val () + "";
})
alert (str);
})
})
-->
</script>
<body>
<form name= "Form1" method= "Post" action= "" >
<input type= "checkbox" id= "All" name= "all" >
<input type= "button" id= "BTN1" value= "Select All" >
<input type= "button" id= "Btn2" value= "deselect All" >
<input type= "button" id= "Btn3" value= "Select All Odd" >
<input type= "button" id= "Btn4" value= "anti-selection" >
<input type= "button" id= "Btn5" value= "Get All values selected" >
<br>
<input type= "checkbox" name= "checkbox" value= "CheckBox1" >
CheckBox1
<input type= "checkbox" name= "checkbox" value= "CheckBox2" >
CheckBox2
<input type= "checkbox" name= "checkbox" value= "Checkbox3" >
Checkbox3
<input type= "checkbox" name= "checkbox" value= "Checkbox4" >
Checkbox4
<input type= "checkbox" name= "checkbox" value= "CHECKBOX5" >
Checkbox5
<input type= "checkbox" name= "checkbox" value= "checkbox6" >
Checkbox6
<input type= "checkbox" name= "checkbox" value= "CHECKBOX7" >
checkbox7
<input type= "checkbox" name= "checkbox" value= "Checkbox8" >
Checkbox8
</form>
Method Two
<input type= "button" class= "BTN_SELECTALLBG" id= "checkall2" value= "Select All"/>
<input type= "checkbox" Name= "groupid[]" value= "Traversal of a column value"/>
Add full selection to all buttons
$ (' #checkall2 '). Toggle (function () {
$ ("Input[name= ' groupid[]"). each (function () {
$ (this). attr (' checked ', true);
});
$ (this). attr (' value ', ' Cancel ');
},function () {
$ ("Input[name= ' groupid[]"). each (function () {
$ (this). attr (' checked ', false);
});
$ (this). attr (' Value ', ' Select All ');
}
);
Method Three
<script type= "Text/javascript"
<!--
$ (document). Ready (function () {
$ ( "#abutton"). Click (function () {$ ("input[@type =checkbox]"). Check ();};
$ ("#ubutton"). Click (function () {$ ("input[@type =checkbox]"). Uncheck ();
});
Jquery.fn.extend ({
Check:function () {return This.each (function () {this.checked = true;});
Uncheck:func tion () {return This.each (function () {this.checked = false;});
}
});
//-->
</script>
<button id= "Abutton" > select all </button>
<button id= "Ubutton" > </button>
<input type= "checkbox" value= "/>a
<input type=" checkbox "value=" "/>b <input type= "checkbox" value= "/>c
<input type=" checkbox "value=" "/>d
<input type=" checkbox " Value= ""/>e