Get all tags from a page : tagName « Javascript Properties « JavaScript DHTML






Get all tags from a page

 

<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()">
<h1>Heading One</h1>
</body>
</html>

   
  








Related examples in the same category