Related Operations for jquery checkbox-Select all, reverse, and get all selected checkbox
1. Select All
$ ("#btn1"). Click (function () {
$ ("Input[name= ' checkbox ']"). attr ("Checked", "true");
})
2, cancel all election (all do not choose)
$ ("#btn2"). Click (function () {
$ ("Input[name= ' checkbox ']"). Removeattr ("checked");
3. Select all odd numbers
$ ("#btn3"). Click (function () {
$ (' input[name= ' checkbox ']:odd '). attr ("Checked", "true");
})
4. Select All even
$ ("#btn6"). Click (function () {
$ (' input[name= ' checkbox ']:even '). attr ("Checked", "true");
})
5. Anti-election
$ ("#btn4"). Click (function () {
$ ("Input[name= ' checkbox ']"). each (function () {
if ($ (this). attr ("checked"))
{
$ (this). Removeattr ("checked");
}
Else
{
$ (this). attr ("Checked", "true");
}
}
)
Or
$ ("#invert"). Click (function () {
$ ("#ruleMessage [name= ' Delmoduleid ']:checkbox"). each (function (i,o) {
$ ( o). attr ("Checked",!$ (o). attr ("checked"));
6, get the value of the selected item
var aa= "";
$ ("#btn5"). Click (function () {
$ (' input[name= ' checkbox ']:checkbox:checked '). each (function () {
aa+=$ ( This). val ()
})
document.write (AA);
})
7. Traverse Selected Items
$ ("input[type=checkbox][checked]"). each (function () {
//Because the check box is generally selected for more than one, you can loop out
alert ($ (this). Val ());
8. Examples
9. Effect Drawing
Thank you for reading, I hope to help you, thank you for your support for this site!