Previous: First click on the Full selection button input display check, the second is not displayed, you need to use prop to add checked properties.
However, a problem with prop will appear, and the checked attribute will not be added (for example: $ ("input[type= ' checkbox '][name= ' che ')"). attr ("checked") gets the result to undefined), This will not be possible through the IF statement to determine whether to select, so as to achieve the reverse function.
Let's get down to the idea: since the "checked" feature is implemented by determining whether there are any properties, the checked property is cleared every time that you perform the "Select All" option, so that the checked property that you added earlier will be cleared every time. The sample code is as follows:
Select All
$ ("#quanxuan"). Click (function () {
$ ("#tb"). Find ("input[type= ' checkbox '][name= ' che ')"). Removeattr (" Checked ");
$ ("#tb"). Find ("input[type= ' checkbox '][name= ' che ']"). Prop ("checked", true);
Reverse-Select
$ ("#fanxuan"). Click (function () {
$ ("#tb"). Find ("input[type= ' checkbox '][name= ' che ')". each (function () {
if (). Is (": Checked")) {
$ (this). Removeattr ("checked");
$ (this). Prop ("checked", false);
else{
$ (this). Removeattr ("checked");
$ (this). Prop ("Checked", "checked");}});
At present, we can only think of this redundancy method, and then come up with a new solution to complement it.
The above is a small set for you to introduce the total selection of the choice of disgusting abnormal situation, very good, with reference value, I hope to help you!