Full-selection invert selection is more practical in data batch operations. This article provides a good example. It mainly involves selecting all items when you click the Select All box.
The Code is as follows:
// Select all button Processing
$ (Function (){
// Click Select All
$ ("# CheckAll"). click (function () {// when you click the Select All box
Var flag = $ ("# checkAll"). is (": checked"); // you can specify the status of the all-selected button.
Var checkItems = document. getElementsByName ("checkItem ");
For (var I = 0; I CheckItems [I]. checked = flag;
}
});
// Click the subitem
$ ("Input: checkbox [name = 'checkitem ']"). each (function (){
$ (This). click (function (){
If ($ ("input: checkbox [name = 'checkitem ']: checked "). length = $ ("input: checkbox [name = 'checkitem ']"). length ){
Document. getElementById ("checkAll"). checked = true;
} Else {
Document. getElementById ("checkAll"). checked = false;
}
});
});
});