The-Eagle-Eye Posted April 9, 2006 Share Posted April 9, 2006 Below are two html files showing example for Collection All and Childern respectively.I want to " ! " this exclamation mark in the output says that its a comment tag,then why it is apperaring after title tag instead of apperaring before head tag? <HTML><!-- some comments --><!-- some comments --><HEAD><TITLE> DHTML - Collection All </TITLE><script LANGUAGE = "JavaScript"> var elements = ""; function start() { for ( var loop = 0; loop < document.all.length; ++loop ) elements += "<BR>" + document.all[ loop ].tagName; pText.innerHTML += elements; }</SCRIPT></HEAD><BODY ONLOAD = "start()"><P ID = "pText">Elements on this Web page:</P></BODY></HTML> <HTML><!-- some comments --><!-- some comments --><HEAD><TITLE> DHTML - Collection Children </TITLE><script LANGUAGE = "JavaScript"> var elements = "<UL>"; function child( object ) { var loop = 0; elements += "<LI>" + object.tagName + "<UL>"; for( loop = 0; loop < object.children.length; loop++ ) { if ( object.children[loop].children.length ) child( object.children[ loop ] ); else elements += "<LI>" + object.children[ loop ].tagName + "</LI>"; } elements += " </UL> "; }</SCRIPT></HEAD><BODY ONLOAD = "child( document.all[ 1 ] ); myDisplay.outerHTML += elements;"><P>Welcome to our <STRONG>Web</STRONG> page!</P><P ID = "myDisplay">Elements on this Web page:</P></BODY></HTML>Thanx in Advance. Link to comment Share on other sites More sharing options...
Little Goat Posted April 10, 2006 Share Posted April 10, 2006 well, I tried it and it did the same thing for me. I don't know why, but maybe the head and title elements get more priority or something. that's my guess. :)LG Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now