<ptml> <pead> <title> Getting the specified elements of the HTML file </title> <script language= "JavaScript" > function get Element1 () {Alert (document.all ("myH2"). TagName); function GetElement2 () {alert (myh2.tagname); function Showtags () {Alert (Document.all.tags ("P"). length); function Showitems () {var strtags = ""; for (var i=0; i<document.all["MyTag"].length; i++) {Objele = document.all ("MyTag"). Item (i); Strtags + + Objele.tagname + ""; alert (strtags); } </script> </pead> <body id= "Mybody" > <p id= "myH2" > get the specified element of the HTML file </p> <pr> ;p id= "MyTag" > Get <b id= "MyTag" >HTML</b> file elements body</p> <p id= "MyTag" > Get <b>html</b > File Elements h2</p> <p id= "MyTag" > Get <b>HTML</b> file elements p</p> <form> <input type= " Button "onclick=" GetElement1 () "value=" gets the specified element "> <input type=" button "onclick=" GetElement2 () "value=" get the specified element " > <input type= "button" onclick= "Showtags() "value=" how many P elements > <input type= "button" onclick= "Showitems ()" value= "show MyTag elements" > </form> </body > </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]