Forum Moderators: open
<div id="container" class="box">
Hello World<br />
</div>
============================================
according to DOM specification i think the <div> element will have 2 child. 1 is text node and another is <br> element node
however when i use javascript to access this i can see three child in <div> element. 1 is text node, 2 <br> element node and 3 is another text node.
my javascript is
============================================
<script>
function getInfo(container)
{
var con = document.getElementById(container);
var info= document.getElementById("info");
for(i=0;i < con.childNodes.length;i++)
{
info.innerHTML = info.innerHTML + "Node Name "+con.childNodes[i].nodeName
+" "+"Node Value "+con.childNodes[i].nodeValue+"<br />";
}
}
</script>
can anyone explain me about this?
thanks you every much for your help
Next is the <br /> element.
And the last text node consists of only a newline character (which is after your <br /> and before your closing </div> tag.
We often forget about these since in HTML whitespace is ignored.