1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8">5 <title>Element Object</title>6 <Scripttype= "Text/javascript">7 //Element Object8 /*9 Get property: GetAttribute (name)Ten Set properties: SetAttribute (name, value) One Delete attribute: removeattribute (name) A */ - </Script> - </Head> the <Body> - <!--<input type= "text" id= "Textid" value= " textcontent"/> - - <ul> - <Li>Aaa</Li> + <Li>Bbb</Li> - <Li>Ccc</Li> + </ul> A <Scripttype= "Text/javascript"> at //Get Input Label - //var input = document.getElementById ("Textid"); - //Get value Values - //document.write (Input.getattribute ("value")); - //Get ID value, use method to get class value can avoid keyword conflict - //document.write (Input.getattribute ("id")); in //Setting Value property values - //Input.setattribute ("value", "newcontent"); to //Delete id attribute, cannot delete Value property + //document.write ("<br/> Original value:" + input.id); - //Input.removeattribute ("id"); the //document.write ("<br/> After deletion:" + input.id); * varul=document.getElementsByTagName ("ul")[0]; $ //the ChildNodes property has poor browser compatibility, so use the getElementsByTagName () methodPanax Notoginseng varLis=Ul.getelementsbytagname ("Li"); - document.write (lis.length); the </Script> + </Body> A </HTML>
JavaScript Base 20--element Object