Select All js check boxes and select all code for jquery check boxes
Select all the check boxes for webpage special effects and select all the code for the jquery check boxes.
<! -- Now that I only provide code for Selecting All and deselected webpage special effects check boxes, today we provide two js checkbox full selection and jquery check box full selection. You can take a look below. -->
<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>