Search code examples
javascriptfirefoxdomgoogle-chromeinternet-explorer

childNodes not working in Firefox and Chrome but working in IE


I have a gridview in its 3rd cell, there is textbox control, I am calling javascript function on onchange.

Can some body tell me why this is not working in Firefox and Chrome but working in IE

grd.rows[rowindex].cells[3].childNodes[0].value

It return correct value in IE but not in Chrome and firefox (In FF and Chrome it return undefined)?

Please also suggest me solution to handle this problem.

Edit

alert(grd.rows[ri].cells[3].childNodes[0].value);//IE value=correct value, FF and chrome value=undfined
alert(grd.rows[ri].cells[3].childNodes[1].value);//IE value=undfined, FF and Chrome value= correct value

Thanks


Solution

  • I believe that this is because IE ignores text nodes that only contain newlines and tabs. Personally I prefer they be ignored but I would rather have consistency across the browsers.

    <p><!-- This comment represents a text node.
        --><em>text</em>
    </p>