Tag: IE

childNodes problem in FF !!!

I was working with js and got a peculiar problem (it’s was unknown to me 😛 😀 🙁 ) about childNodes count in firefox and opera. Internet explorer showed perfectly. suppose my html is like

<ul id="ul_id">
<li id="id1"> One</li>
<li id="id2"> Two</li>
</ul>

Now the js:

objFather = document.getElementById('ul_id'); //get the father  ul' ID
arrayChildren = objFather.childNodes; //geting array of children
childNum = arrayChildren.length;

Here childNum will give diff values for diff browser. FF, Opera counts the whitespaces . textnodes as child but IE is normal in this case.

Usefull link: One