[ACCEPTED]-How can I show an element that has display: none in a CSS rule?-html

Accepted answer
Score: 82

Because setting the div's display style property to 7 "" doesn't change anything in the CSS rule 6 itself. That basically just creates an "empty," inline CSS 5 rule, which has no effect beyond clearing 4 the same property on that element.

You need 3 to set it to something that has a value:

document.getElementById('mybox').style.display = "block";

What 2 you're doing would work if you were replacing 1 an inline style on the div, like this:

<div id="myBox" style="display: none;"></div>

document.getElementById('mybox').style.display = "";
Score: 13
document.getElementById('mybox').style.display = "block";


Score: 6

try setting the display to block in your 1 javascript instead of a blank value.

Score: 2

I can see that you want to write you own 6 short javascript for this, but have you 5 considered to use Frameworks for HTML manipulation 4 instead? jQuery is my prefered tool for 3 such a task, eventhough its an overkill 2 for your current question as it has SO many 1 extra functionalities.

Have a look at jQuery here

More Related questions