Home  >  Article  >  Web Front-end  >  The checked attribute of radio or checkbox in IE cannot be selected and displayed in the initial state_javascript skills

The checked attribute of radio or checkbox in IE cannot be selected and displayed in the initial state_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:49:161319browse

In IE, when using checkbox or radio, you will find that sometimes the checkbox or radio cannot be pre-selected through the CheckBoxObject.checked = true or CheckBoxObject.setAttribute('checked', true) method.
The way to solve this problem is to use the defaultChecked attribute of checkbox or radio to set the defaultChecked attribute to true. The specific implementation is CheckBoxObject.setAttribute('defaultChecked', true) or CheckBoxObject.defaultChecked= true, so that Implement checkbox and radio to be selected in the initial state in IE.
Specific example:

Copy code The code is as follows: