JS Table element checked, radio selected several methods (detailed) _javascript skills

Source: Internet
Author: User

0. Environment

<input type= "checkbox" value= "LOL"/>lol

var lol = document.getelementsbytagname ("input") [0];

1, HTML DOM

A.lol.checked = true;

The value of the property can be not lol, as long as it is true when converted to a Boolean value, only true, false two when the value is taken

No checked markup added

B.lol.click ();

The checked tag is not incremented, then the lol.checked value is True

2. DOM Core

Lol.setattribute ("Checked", "checked");

Element adds a checked tag, then the lol.checked value is True

<input type= "checkbox" checked= "checked" value= "LOL"/>lol

In fact, checked tag, the existence of the application, the following wording can be implemented by default selected

<input type= "checkbox" checked value= "LOL"/>lol

Selected by default when the browser parses text.

The above JS table cell element checked, radio selected several methods (detailed) is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.

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.