Js-001-javascript operation one of the common web elements-radio Check

Source: Internet
Author: User

This article mainly for the common elements of the Web page (such as: radio button, check button) JavaScript operation, for a simple source code sample demonstration, please refer to the small master. If there is any deficiency, please ask the great God to correct me, I appreciate it!

Words do not say much, directly on the code:

1 <HTML>2     <Head>3         <MetaCharSet= ' Utf-8 '>4 5         <title>Js-001-javascript operation one of the common web elements-radio Check</title>6 7         <Linkrel= "stylesheet"type= "Text/css"href= "Global.css">8     </Head>9         Ten     <Body> One         <DivID= "single"> A             <h4>Single-option operation:</h4> -             <Li>Get Radio list: document.getElementById (' Radio ')</Li> -             <Li>Click on the Radio list for the second item: document.getElementById (' Radio '). Children[3].click ()</Li> the             <Li>Check the radio list for the second item: document.getElementById (' Radio '). children[3].checked</Li> -              -              -             <formID= "Radio"> +                 <label>Rating:</label> -                 <inputtype= "Radio"name= "Level"value= "0"></input><label>Principal</label> +                 <inputtype= "Radio"name= "Level"value= "1"></input><label>Excellent</label> A                 <inputtype= "Radio"name= "Level"value= "2"></input><label>Medium</label> at                 <inputtype= "Radio"name= "Level"value= "3"></input><label>So so</label> -             </form> -         </Div> -  -         <DivID= "Multi"> -             <h4>Complex options Operation:</h4> in             <Li>Get a checkbox list: document.getElementById (' checkbox ')</Li> -             <Li>Click the second element of the checkbox list: document.getElementById (' checkbox '). Children[1].click ()</Li> to             <Li>View the selected state of the checkbox's entry: document.getElementById (' checkbox '). children[0].checked</Li> +              -              the             <formID= "checkbox"> *                 <label>Take:</label> $                 <inputtype= "checkbox"name= "Level"value= "0"><label>Tai chi</label>Panax Notoginseng                 <inputtype= "checkbox"name= "Level"value= "1"><label>Sanda</label> -                 <inputtype= "checkbox"name= "Level"value= "2"><label>Piano</label> the                 <inputtype= "checkbox"name= "Level"value= "3"><label>Dance</label> +                 <inputtype= "checkbox"name= "Level"value= "4"><label>Erhu</label> A             </form> the         </Div> +             -         <Div> $             <BR><BR><BR><BR> $             <ahref= "Http://www.w3school.com.cn/jsref/dom_obj_style.asp"Target= "_blank">HTML DOM Style Object</a> -         </Div> -     </Body> the </HTML>

Save the above source to an HTML file, open it in Chrome, as shown in:

After executing the corresponding JS script, the following is displayed:

At this point, Js-001-javascript operates one of the common web elements-the radio check is completed successfully, and hopefully this article will give you a reference to the beginner JavaScript.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

Js-001-javascript operation one of the common web elements-radio Check

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.