If you use jquery 1.6, code if (elem). attr ("Checked"), you will get an attribute that does not change the check box is selected and selected. It is simply used to store the initial value of the default or selected property. To maintain backward compatibility, the. attr () method starts with the JQuery 1.6.1+ and, in addition to returning property values, the property properties are updated, so the Boolean attribute (Boolean property) does not need to pass. Prop () to change its value. It is recommended to use one of the above methods to obtain the checked value.
Using the attr method of jquery to get and set the "checked" property of the check box, it is found that the first full selection/cancellation is valid, and then it is invalid, but viewing the HTML source file, the checkbox properties have been updated, and the correct way to do this is not to update the page:
<script type= "Text/javascript" src= "Http://code.jquery.com/jquery-1.11.1.min.js" ></script><script type= "Text/javascript" >//<! [Cdata[$ (function () {$ ('. Ckall '). Click (function () {$ (". Box-items"). each (function () {$ (this). Prop ("Checked",!!
$ (". Box-all"). Prop ("checked"));
});
});
}); ]]></script> <div><label class= "Ckall" ><input class= "Box-all" type= "checkbox"/>< Span> Select </span></label> <input class= "Box-items" type= "checkbox"/> <input "class=" type= "checkbox"/> <input class= "box-items" type= "checkbox"/> <input "class=" box-items "checkbox"/ > <input class= "box-items" type= "checkbox"/> </div>