javascript - 无法在 IE 11 中获取未定义或 null 引用的属性 'style'

标签 javascript internet-explorer

我收到错误“无法获取 null 引用的属性样式”,因为“a”的值在 IE 11 中为 null。但是相同的代码在 IE 8 中工作正常。元素 a 在div 标签。不确定这里有什么问题。

document.getElementById("a").style.display = "block";

<div id="a" style="display:none"><img src="/images/ajax-loader.gif" /></div>

最佳答案

属性 src 中缺少开头 "

<img src="/images/ajax-loader.gif" />

关于javascript - 无法在 IE 11 中获取未定义或 null 引用的属性 'style',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30633017/

相关文章:

javascript - 如何将值从模板传递给 ts 函数

javascript - 是否有任何使用@HostListener 改变方向的窗口事件,就像我们有@HostListener ("window:scroll", ['$event' ]) 用于滚动?

javascript - 我们如何调查浏览器进行了多少次回流?

javascript - 带 babel 的 Vue.js(用于 IE9 兼容性),无需节点构建步骤

angularjs - 使用 AngularJS 绑定(bind)处理 IE 的清除按钮

javascript - 如何使用express JS以特定方式从URL读取参数

javascript - Angularjs 跨源资源共享 (CORS) post 或 put 方法在 IE8 和 IE9 中不起作用

css - 在 IE 怪癖模式下垂直对齐 li 标签内的多行文本

css - 如何使此 Google 字体在 Internet Explorer 11 上工作

javascript - 解决来自 JSON 对象的循环引用