Properties of the Action element
<span style= "Font-family:courier new;font-size:14px;" ><body> <ul id= "City" > <li id= "BJ" > Beijing </li><li id= "TJ" > Tianjin </li>< Li id= "NJ" > Nanjing </li> </ul> </body></span>
1. Get the attribute name of the element
<span style= "Font-family:courier new;font-size:14px;" ><script type= "Text/javascript" > //Get the Name property value of Beijing node in the page//1 get Beijing node var bjelement = document.getElementById ( "BJ");//2 gets the name property of the Beijing node var arr = Bjelement.name;var arr = bjelement.getattribute ("name");</span>
<span style= "Font-family:courier new;font-size:14px;" ></script></span>
* In actual development, use the ". Attribute name" or the GetAttribute () method?
* * ". Property name": Some browsers do not support it.
* * GetAttribute (attribute name) method: Almost all browsers are supported.
* * Recommended use of the GetAttribute () method.
2. Setting property values for property names
Set the Name property for the page Beijing node: name= "Beijing"//1 get beijing node var bjelement = document.getElementById ("BJ");//2 Set the property Bjelement.setattribute ("name", "Beijing");
3. Remove the properties of a label
<span style= "Font-family:courier New;" >//Delete the name attribute Bjelement.removeattribute ("name") of the Beijing node in the page;</span>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JavaScript Element Object