The following are the implementation ideas, have been tested, for reference
var allset = document.getElementById (' Allset '); Get the Select All button element
var a = allset.custom; Custom properties for the Select All button
a = 0; Custom attribute value is 0
var input1 = all.getelementsbytagname (' input '); Get all the input tags under all;
Add Click events to the Select All button to make judgments;
Allset. onclick = function () {
If A is 0, the first for loop is executed;
if (a = = 0) {
Loops through all input tags;
for (i = 0; i < input1.length; i+ +) {
Leave the input label selected (checked = true selected), (checked = False unchecked );
input1[i].checked = true;
The value of the custom property is changed here to 1
a = 1
}
}
// If a for 1 executes the next for loop, leave the input label unchecked
else{
for (i = 0; i < input1.length; i+ +) {
input1[i].checked = false;
A = 0
}
}
}
JavaScript implementation Click Select all, again click Cancel Select All