childNodes在Firefox和Chrome中不工作,但在IE中工作 [英] childNodes not working in Firefox and Chrome but working in IE

查看:132
本文介绍了childNodes在Firefox和Chrome中不工作,但在IE中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview在它的第三个单元格,有文本框控件,我在onchange上调用javascript函数。



有些身体告诉我为什么这不工作在Firefox和Chrome中,但在IE中工作

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

它在IE中返回正确的值,但不在Chrome和Firefox中(在FF并且Chrome返回未定义)?



请同时建议我解决这个问题的解决方案。



修改

  alert(grd.rows [ri] .cells [3]。 childNodes [0] .value); // IE value =正确的值,FF和chrome值= undfined 
alert(grd.rows [ri] .cells [3] .childNodes [1] .value); // IE值=未定义,FF和Chrome值=正确值

谢谢

解决方案

我相信这是因为IE忽略只包含换行符和标签的文本节点。个人而言,我更喜欢被忽略,但宁可在浏览器中保持一致。

 < p><! - 注释表示文本节点。 
- >< em> text< / em>
< / p>


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

解决方案

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>

这篇关于childNodes在Firefox和Chrome中不工作,但在IE中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆