Js form elements checked, radio Selected methods (detailed description), checkedradio

Source: Internet
Author: User

Js form elements checked, radio Selected methods (detailed description), checkedradio

0. Environment

<Input type = "checkbox" value = "lol"/> lol

Var lol = document. getElementsByTagName ("input") [0];

1. HTML DOM

A. lol. checked = true;

The attribute value can be not lol, as long as the value is true when it is converted to a Boolean value. The value can only be true or false.

No checked flag is added

B. lol. click ();

The checked flag is not added. The value of lol. checked is true.

2. DOM core

Lol. setAttribute ("checked", "checked ");

When the checked Mark is added to the element, the value of lol. checked is true.

<Input type = "checkbox" checked = "checked" value = "lol"/> lol

In fact, the checked Mark exists as an application, and the following method can be selected by default.

<Input type = "checkbox" checked value = "lol"/> lol

It is selected by default when the browser parses the text.

The above js form elements checked and radio have been selected several methods (detailed description) are all the content that I have shared with you. I hope to give you a reference and support for the help house.

Related Article

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.