Properties and methods for document objects
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html> <head> <title>Test10.html</title> <script type="Text/javascript"> //document Properties of an object /*alert (Document.referrer); Alert (document. URL); * / Methods for//document objects function change(){ varobjspan=$ ("Heihei"); Objspan.innerhtml="Summer Class"; } function getallhobbies(){ varHobbies=document.getelementsbyname ("Hobby"); for(varI=0; i"MSG"). innerhtml+=hobbies[i].value+" "} } function getallinputs(){ varInputs=document.getelementsbytagname ("Input"); for(varI=0; i<inputs.length;i++) {document.getElementById ("MSG"). innerhtml+=inputs[i].value+" "} }//Factory function to simply get the element with the specified ID function $(ID){ returndocument.getElementById (ID); }</script> </head> <body> <a href="javascript:location.href= ' test01.html '">test01</a><br/> <input type="button" value="Flush" onclick=" Location.reload (); " /><br/> <input type="button" value="forward" onclick ="History.go (1)"/><br/> <input type="button" value="Back" onclick=" History.back (); " /><br/> <span id="Heihei">wbs14061</span><input type="button" value="variable" onclick="Change () " /> <br/> <h4>Please choose your hobby:</h4> <input type="checkbox" name="Hobby" value ="Game" />Play games <input type="checkbox" name= "hobby" value="movie " />Watch movies <input type="checkbox" name="Hobby" value= "Sport" />Sports <input type="checkbox" name= "hobby" value="Eat" />Dining <input type="button" value="Get all Hobbies" onclick ="Getallhobbies ()" /><br/><br/> <input type="button" value="Get all input elements" onclick= "getallinputs ()" /> <hr/> <div id="msg"></div> </body></html>
Javascript-document Object Properties and methods