Modify properties in JS

Source: Internet
Author: User

<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >
<script type= "Text/javascript" >
Window.onload=function () {
Read-Write attribute node
Attribute node is a property of a specified element node
(1) Get the specified element node first
var nameNode = document.getElementById ("name");
(2) The value of the specified property is read
alert (Namenode.value);
(3) Setting the value of the specified property
Namenode.value= "Good magic";
/**var Bjnode = document.getElementById ("BJ");
Alert ("I want to go to Beijing");
var bqnode = document.getelementsbytagname ("Li");
Alert ("This is tagged with!!!! ");
var nameNode = document.getelementsbyname ("Sex");
Alert ("This is based on the name attribute"); **/
}

</script>
<body>
<p> the city:</p> you want to go
<ul id= "City" >
<li id= "BJ" name= "Beijing" > Beijing </li>
<li> Shanghai </li>
</ul>
<br></br>
<p> The games you like:</p>
<ul id= "Game" >
<li id= "LOL" > League of Legends </li>
<li> Warcraft </li>
</ul>
<br></br>
Sex
<input type= "Radio" name= "Sex" value= "man"/> Male
<input type= "Radio" name= "Sex" value= "women"/> Female
<br></br>
Name
<input type= "text" name= "UserName" value= "name" id= "name"/>

</body>

Modify properties in JS

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.