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+=" <br><br> TAG: "+document.all[i].tagName;
if(document.all[i].children.length>0)
data+=" <b> ITS CHILD : </b>";
for(var j=0;j<document.all[i].children.length;j++)
data+=" "+document.all[i].children[j].tagName;
}
para.innerHTML+=data;
}
</script>
</head>
<body>
<p id="para">Hi Welcome</p>
<input type="button" onclick="start()" value="Click me" >
</body>
</html>
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+=" <br><br> TAG: "+document.all[i].tagName;
if(document.all[i].children.length>0)
data+=" <b> ITS CHILD : </b>";
for(var j=0;j<document.all[i].children.length;j++)
data+=" "+document.all[i].children[j].tagName;
}
para.innerHTML+=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