The checked property of radio or checkbox in IE cannot be checked in the initial state _javascript tips

Source: Internet
Author: User
In IE, when using a checkbox or radio, you may find that you cannot sometimes pass checkboxobject.checked = True or Checkboxobject.setattribute (' checked ', true) Method of making a checkbox or radio by preselection.
The solution to this problem is to use the defaultchecked properties of the checkbox or radio to set the Defaultchecked property to True, and the implementation is Checkboxobject.setattribute (' Defaultchecked ', True, or checkboxobject.defaultchecked= true, so that the checkbox and radio are selected in the initial state of IE.
Specific examples:
Copy Code code as follows:

<script type= "Text/javascript" ><!--
var test1= document.getelementbyid ("Checkboxid");
Test1.setattribute (' defaultchecked ', true);
--></script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.