为什么Mozilla FF不更新innerHTML? [英] Why Mozilla FF does not update innerHTML?

查看:108
本文介绍了为什么Mozilla FF不更新innerHTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变一个HTML元素的CSS动态...为此我使用了innerHTML。

I'm trying to change the CSS of an HTML element dynamically...for that purpose i am using innerHTML.

我面对的问题是,也许Mozilla在第一篇文章中记得textarea的innerHTML。因此,如果用户在textarea中编辑文本,则无法显示新文本并在textarea中显示原始文本。在IE中它工作正常。

The problem I'm facing is, maybe Mozilla remembers the innerHTML of a textarea on the first posting. So if the user edits the text in textarea, it fails to show new text and shows original text in textarea. In IE it works fine.

innerHTML和mozilla firefox有什么不对?

What's wrong with innerHTML and mozilla firefox ?

<html>
<head>
<title></title>
<script type="text/javascript">
function abc()
{
    alert(document.getElementById("c").innerHTML);
}
</script>
</head>
<body>
<textarea id="c" onclick="abc()">hello...</textarea>
</body>
</html>


推荐答案

关于您的要求,您为什么不做:

Regarding your requirement, why don't you just do:

document.getElementById("c").className = "myCSSClass";

因为使用 innerHTML 来更改CSS类的元素似乎很奇怪...

because using innerHTML to change the CSS class of an element seems pretty weird...

这篇关于为什么Mozilla FF不更新innerHTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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