无法读取属性'style'的null [英] Cannot read property 'style' of null
本文介绍了无法读取属性'style'的null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于一些奇怪的原因,我得到一个奇怪的错误。
For some strange reason I get a weird error.
我有一个元素(我用PHP定义),最终看起来像这样:
I have an element (which I'd defined with PHP) that eventuly looks like this:
<span id="l_area_1_5" style="display: inline; ">
...some html inputs and stuff....
</span>
我确定Chrome的Inspect Element。
Which I am certain by Inspect Element of the Chrome.
现在当我尝试以编程方式解决它:
Now when I try to address to it programaticly with this:
document.getElementById("1_area_1_5").style.display = 'none';
我得到无法读取属性'style'的null
错误。
我不知道这到底是什么意思,任何帮助?
I have no idea what the hell that's supposed to mean, any help?
推荐答案
错误表示该元素不存在。这是因为你有一个错字。你写了 1
而不是 l
。
The error means that the element doesn't exist. It's because you have a typo. You wrote 1
instead of l
.
l_area_1_5
1_area_1_5
^
这篇关于无法读取属性'style'的null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文