- /**
- * Select All
- */
- function Checkall () {
- $ ("input[name=ids]"). attr ("Checked", true);
- }
- /**
- * All not selected
- */
- function Uncheckall () {
- $ ("input[name=ids]"). attr ("Checked", false);
- }
Problem Description:
The initial status check box does not have a full selection,
Click the Select All button to call the Checkall method,
A full selection is achieved,
Then click the Uncheck All button,
To achieve a complete no-election,
Then click the Select All button again,
The result is a full selection of wood,
Then repeatedly click on the wood to have any reaction.
Google's:
Replace the attr method with the prop method,
- /**
- * Select All
- */
- function Checkall () {
- $ ("input[name=ids]"). Prop ("checked", true);
- }
It worked.
Prop () Gets the property value of the matching element.
This method is jquery1.6 later, used to differentiate the previous. attr () method.
One of the biggest differences is the Boolean attribute, which is used after 1.6. The prop () method is fine.
This boolean attribute, again explained, is the attribute value only True|false property.
There is also the case that only the attribute name is added, and the same can be used without writing property values. The prop () method. For example: checked, disable and so on, in fact, they are still belong to the Boolean type attribute.
1. Add property name This property will take effect should use Prop ();
2. There are true,false two attributes using prop ();
3. The other uses attr ();
jquery checkbox repeated calls to attr (' checked ', true/false) only take effect for the first time