Read-Write attribute node:
1) The value of the attribute node can be obtained and set directly through Citynode.id.
2) Get the attribute node through the GetAttributeNode method of the element node,
and read and write the property values through NodeValue.
1<HTML>2 <Head>3 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">4 <title>Untitled Document</title>5 6 <Scripttype= "Text/javascript">7 8 //read-Write attribute node: Gets the property value and sets the property value by the element node.9 window.onload= function(){Ten One //The attribute node is a property of a specified element node. A //1. Get the specified element node first - varNameNode=document.getElementById ("name"); - the //2. Read the value of the specified property again - alert (namenode.value); - - //3. Set the value of the specified property. + Namenode.value= "still Silicon Valley"; - + //var nameattr = Namenode.getattributenode ("value"); A //alert (nameattr); at //alert ("--" + nameattr.nodevalue); - //nameattr.nodevalue = "Atguigu"; - } - - </Script> - in </Head> - <Body> to <P>Which city do you like?</P> + <ulID= "City"> - <LiID= "BJ"name= "Beijing">Beijing</Li> the <Li>Shanghai</Li> * <Li>Tokyo</Li> $ <Li>Seoul</Li>Panax Notoginseng </ul> - the <BR><BR> + <P>Which stand-alone game do you like?</P> A <ulID= "Game"> the <binID= "RL">Red Police</Li> + <Li>Live</Li> - <Li>Need for Speed</Li> $ <Li>Warcraft</Li> $ </ul> - - <BR><BR> theName<inputtype= "text"name= "username" - ID= "Name"value= "Atguigu"/>Wuyi </Body> the </HTML>
JavaScript DOM Programming--03--read-write attribute node