July 29, 2008 | Posted by Manchumahara(Sabuj Kundu) in category Java script with tags , , ,

I was working with js and got a peculiar problem (it’s was unknown to me :P :D :( ) 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

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Additional comments powered by BackType

feedback