Mega Code Archive

 
Categories / JavaScript Tutorial / Document
 

List all elements by reference the document all

< html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- function findhead1() {     var tag, tags;     tags = "The tags in the page are:"     for(i = 0; i < document.all.length; i++)     {         tag = document.all(i).tagName;         tags = tags + "\r" + tag;     }     document.write(tags); } //  --> </script> </head> <body onload="findhead1()"> <h1>Heading One</h1> </body> </html>