Hi there,
I'm very new to Javascript and am just playing around with some coding (loving it so far). However, I've hit a bit of a snafu:
The nodeType/nodeName printed are:Code:myDiv = document.getElementById("parentDiv"); for ( i = 0; i < myDiv.childNodes.length; i++ ) { with (myDiv.childNodes[i]) { document.writeln(nodeType + "<br>"); document.writeln(nodeName + "<br>"); document.writeln(nodeValue + "<br>"); document.writeln(this instanceof HTMLElement); document.writeln(this instanceof HTMLDivElement); if ( nodeType == 1 ) { var id = getAttribute("id"); document.writeln(id + "<br>"); document.writeln(className + "<br>"); } } }
3, #text
1, DIV
3, #text
1, DIV
3, #text
That's correct. However, what is puzzling me is that all five of these return true for "this instanceof HTMLElement" and all five return false for "this instanceof HTMLDivElement".
My understanding was that the #text ones would return false for both and the DIV ones would return true for both.
What am I missing here?
Thanks,
Will


Reply With Quote
Bookmarks