“innerText"在 IE 中有效,但在 Firefox 中无效 [英] 'innerText' works in IE, but not in Firefox

查看:33
本文介绍了“innerText"在 IE 中有效,但在 Firefox 中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些可在 IE 中运行的 JavaScript 代码,其中包含以下内容:

I have some JavaScript code that works in IE containing the following:

myElement.innerText = "foo";

但是,似乎innerText"属性在 Firefox 中不起作用.是否有一些 Firefox 等价物?或者是否有更通用的跨浏览器属性可以使用?

However, it seems that the 'innerText' property does not work in Firefox. Is there some Firefox equivalent? Or is there a more generic, cross browser property that can be used?

推荐答案

Firefox 使用 W3C 兼容 textContent 属性.

Firefox uses the W3C-compliant textContent property.

我猜 Safari 和 Opera 也支持这个属性.

I'd guess Safari and Opera also support this property.

这篇关于“innerText"在 IE 中有效,但在 Firefox 中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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