DOM Tree Traversal and Modification

Leave a Comment

The main intention of objects is to use the collection of all the related objects on the web page. There is a special object model collection called all which is used to refer all the HTML elements. If we want to represent all the HTML elements then the object model collection all is used. The order in which these HTML elements come in our program i the same order all those elements will be displayed. In the following program we have used all in order to display all the HTML tags used by our program.

DHTML Program
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Object model Demo</title>
<script type="text/javascript">
var web_page_element="";
function Display()
{
for(i=0;i<document.all.length;i++)
web_page_element+="<br>" +document.all[i].tagName;
pmsg.innerHTML+=web_page_element;
}
</script>
</head>
<html>
<body onload="Display()">
<p id="pmsg" ><strong>Varous tags used in this web document are:</strong></p>
<center><i> This is how we can enlist the tags used on the web page</i></center>
</body>
</html>
Output in Browser


0 comments:

Post a Comment