child nodes array problem in IE7/8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hiren Dave
    New Member
    • Aug 2010
    • 2

    #1

    child nodes array problem in IE7/8

    Hello,

    I am facing a strange problem. I have written following code.

    el.parentNode.p arentNode.child Nodes[1].style.color="w hite";

    In FireFox and Chrome it works but in IE it gives me following error.

    childNodes.1.st yle is null

    I really don't know what is the reason for this error.Can someone please tell me the reason.

    Thanks in advance for help.

    Regards,
    Hiren Dave
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    standard compliant browsers treat whitespace between tags as a child node (according to the DOM), while IE only counts the element nodes.

    Ex
    Code:
    <parent>
    <child/>
    </parent>
    are 1 child node in IE and 3 child nodes [text node (line break), element node, text node (line break)] in all others.

    Comment

    • Hiren Dave
      New Member
      • Aug 2010
      • 2

      #3
      Thanks Dormilich.

      It really helped me to solve my problem.

      Comment

      Working...