Use statement $. attr (checked, true): Change the attribute of the check box to be selected. The first time you click "valid" in chrome, it won't work. IE8 is no problem when you select all the check boxes, A problem occurs. Use the statement $. attr ('checked', true): Change the attribute of the check box to be selected. The first time you click "valid" in chrome, it will not work. IE8 is correct.
Baidu has been searching for a long time because HTML attributes are divided into attribute and property. The latter is called a feature for the moment.
The checked attribute is divided into attribute-> checked, and property-> true, false.
For a checkbox, if checked = "checked" is not defined, the result of alert ($. attr ("checked") is undefined. If defined, the result is checked. Attribute does not change with the status of the checkbox.
If prop ($. attr ("checked") is used, the output values are false and true, respectively. Property changes as it changes.
Therefore, you must use prop () to modify the checked attribute (). Prop () is added after jQuery1.6.
Other charts with similar attributes on the Internet:
In versions earlier than IE9, if the property is not deleted before the DOM element is removed. setting the DOM element property (except for the simple type: number, string, and boolean) in the prop () method may cause memory leakage. To safely set the DOM object Value and avoid Memory leakage, you can use the. data () method. You have not encountered it yet. Remember it here first.