技术开发 频道

解决 .setAttribute 添加JS或者CSS 在IE下不起作用


【IT168技术文档】

document.getElementById("divid").setAttribute("onmouseout", "javascript:this.style.backgroundColor='#fff'");
  上面这行代码在Firefox 下能正常运行,然后放在IE下却不能运行.因为在IE下这行代码没有生效

  给上面一行代码稍作修改就能使它兼容在IE和FF下.
document.getElementById("divid").onmouseout = function(){ document.getElementById("divid").style.backgroundColor = "#fff"; }
0
相关文章