由于一些奇怪的原因,我得到了一个奇怪的错误。
我有一个元素(我用 PHP 定义的)最终看起来像这样:
<span id="l_area_1_5" style="display: inline; ">
...some html inputs and stuff....
</span>
我通过 Chrome 的 Inspect Element 确定。
现在,当我尝试用这个编程方式解决它时:
document.getElementById("1_area_1_5").style.display = 'none';
我收到 Cannot read property 'style' of null
错误。
我不知道这到底是什么意思,有什么帮助吗?
最佳答案
错误意味着该元素不存在。那是因为你打错了你写了 1
而不是 l
。
l_area_1_5
1_area_1_5
^
关于javascript - 无法读取 null 的属性 'style',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8113729/