Sunday, August 23, 2015

COLLECTIONS IN HTML (Dynamic Object Model Using JS)

Collections: 
It is an array of all the elements(tags) that are present in the html page.

documemt.all==> Is a collection/array of all the elements in the html page in the order in which they appear on the html page..

documemt.all.length==>Is used to find out howmany elements/tags are there in the html page.

document.all[index].children==>Is an array/collection of all the immediate child-elements of the all[index] element.

document.all[index].children.length==>Is used to find out howmany elements/tags are there inside the all[index] element/tags.


<html>
<head>
<script>
var data=" THE TAGS ARE:";
function start()
{
for(var i=0;i<document.all.length;i++)
data+="  "+document.all[i].tagName;
para.innerText+=data;
}

</script>
</head>
<body>
<p id="para">Hi Welcome</p>
<input type="button" onclick="start()" value="Click me" >
</body>
</html>

No comments:

Post a Comment