Unable to read property 'style' of null

For some strange reason, I get a strange error.

I have an element (which I defined with PHP) that will look like this:

<span id="l_area_1_5" style="display: inline; "> ...some html inputs and stuff.... </span> 

What I'm sure about checking for a Chrome item.

Now when I try to access it programmatically with this:

 document.getElementById("1_area_1_5").style.display = 'none'; 

I get Cannot read property 'style' of null error.

I have no idea what the hell that means, any help?

+7
source share
1 answer

An error means that the item does not exist. This is because you have a typo. You write 1 instead of l .

 l_area_1_5 1_area_1_5 ^ 
+13
source

All Articles