我正在尝试使用JavaScript来更新html标签中的文本。通过javascript问题IE8标签更新
它适用于除IE8以外的所有浏览器。在IE8中,标签似乎更新但不显示在屏幕上。
我在下面创建了演示代码,演示了这个问题。
由于
<html>
<head>
<script>
function sendRequest() {
document.getElementById('errormessage').textContent="test";
alert("textContent : "+document.getElementById('errormessage').textContent);
}
</script>
</head>
<body>
<a href="javascript:void(0)" onclick="sendRequest();"> Click me</a>
<br/>
<label id="errormessage" style="color:#F00"> </label>
</body>
</html>
感谢。它似乎因浏览器而异。 – Schaffer 2012-02-20 23:54:58
你可以使用jQuery,它应该照顾浏览器的不一致。 – elclanrs 2012-02-20 23:56:25
使用jQuery解决innerHTML中的浏览器不一致问题?怎么样? – RobG 2012-02-21 00:17:49