通过javascript问题更新IE8标签 [英] IE8 label update via javascript issue

查看:117
本文介绍了通过javascript问题更新IE8标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用javascript来更新html标签中的文本。

I am trying to use javascript to update the text in a html label.

它适用于除IE8之外的所有浏览器。在IE8中,标签似乎已更新,但未显示在屏幕上。

It works in all browsers except IE8. In IE8 the label appears to be updated but is not displayed on the screen.

我在下面创建了演示代码,显示了问题。

I've created demo code below that shows the issue.

谢谢

<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">&nbsp;</label>
</body> 
</html>


推荐答案

document.getElementById('errormessage').innerHTML="test";

这篇关于通过javascript问题更新IE8标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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