JavaScript DHTML/Javascript Properties/tagName

Материал из Web эксперт
Перейти к: навигация, поиск

Get all tags from a page

   <source lang="html4strict">

<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\n" + tag;
   }
   alert(tags);

} </script> </head> <body onload="findhead1()">

Heading One

</body> </html>

 </source>