1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD">2 <HTML>3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">5 <title>Untitled Document</title>6 7 <Scripttype= "Text/javascript">8 9 //Get text nodeTen window.onload= function(){ One A //the text node must be a child node of the element node. - - //1. Get the element node where the text node resides the varBjnode=document.getElementById ("BJ"); - - //2. Defined by FirstChild to a text node - varBjtextnode=Bjnode.firstchild; + - //3. Read and write the value of the text node by manipulating the NodeValue property of the text node. + alert (bjtextnode.nodevalue); A at Bjtextnode.nodevalue= "still Silicon Valley"; - - //alert (bjtextnode); - } - - </Script> in - </Head> to <Body> + <P>Which city do you like?</P> - <ulID= "City"> the <LiID= "BJ"name= "Beijing">Beijing</Li> * <Li>Shanghai</Li> $ <Li>Tokyo</Li>Panax Notoginseng <Li>Seoul</Li> - </ul> the + <BR><BR> A <P>Which stand-alone game do you like?</P> the <ulID= "Game"> + <LiID= "RL">Red Police</Li> - <Li>Live</Li> $ <Li>Need for Speed</Li> $ <Li>Warcraft</Li> - </ul> - the <BR><BR> -Name<inputtype= "text"name= "username" Wuyi ID= "Name"value= "Atguigu"/> the </Body> - </HTML>
JS Get text node