<Script>
// Not in form:
Function checkall ()
{
Arr = new array ("aa", "bb", "cc", "dd ");
For (var I = 0; I <arr. length; I ++)
{
Var e = arr [I];
Eval (document. getelementbyid (e). checked = (document. getelementbyid (e). checked! = True? True: false );
}
}
Function checkall (form) // pass a form as a parameter
{
For (var I = 0; I <form. elements. length; I ++) // Loops the elements in this form.
{
Var e = form. elements [I]; // One-by-one element judgment
If (e. name! = "Chkall" & e. disabled! = True) // if the name attribute of this element is chkall and disabled! = True. That is, when the control is available.
E. checked = form. chkall. checked; // The checked of the control element is consistent with the checked of the selected control.
}
}
// Code of the check box for selecting all juqery checkbox
$ (Document). ready (function (){
// Define the name of the all-selected box as $ chkall
Var $ chkall = $ ('# checkedall ');
Var $ chkarry = $ ('input [type = "checkbox"] '). not ($ (' # checkedall '); // Obtain the check boxes except the all check boxes.
// The implementation function of the all-selected box
$ Chkall. click (function (){
Var B = $ (this). attr ('checked'); // obtain the value of the all-selected box.
$ Chkarry. each (function () {$ (this ). attr ('checked', B) ;}); // You can synchronize the values of other check boxes with the select all option to select all or cancel the select all option.
});
// Check boxes except all
$ Chkarry. each (function (){
$ (This). click (function (){
// First assign the value of each other check box to the entire selection box
$ Chkall. attr ('checked', $ (this). attr ('checked '));
// Check whether all other check boxes have been selected for recycling. If all the check boxes are selected, the system will synchronize them.
// If all other check items have been selected, select both.
$ Chkarry. each (function (index) {$ chkall. attr ('checked', ($ chkall. attr ('checked') & $ chkarry. eq (index ). attr ('checked '))? True: false );});
});
});
});
</Script>