Cirrostratus Cirrostratus - 3 months ago 14
CSS Question

Attempting to change CSS using document.getElementById not working?

I'm attempting to change the CSS of a display:none to a display:block using the following command:


The problem is, despite defining the pop-up id in the css (see below), and following other instructions similar to this problem, I've not been able to get it to change.

#pop-up {
display: none;

What am I doing wrong?


getElementById is a function (not an object where every element with an ID exists as a property).

You need to call it with () and not access properties with []

Make sure you open the Developer Tools in your browser and read the console. It would have told you that document.getElementById["pop-up"] was undefined.