NullPoiиteя NullPoiиteя - 2 months ago 6
CSS Question

how to display a div triggered by onclick event

I have have two

div
s. I want to display a
div
( which has other
div
s inside it ) when the
onclick
event is triggered.

Any help or suggestion would be appreciated.

Mockup of a div containing a submit button and another div

Answer

Here you go:

div{
    display: none;
}

document.querySelector("button").addEventListener("click", function(){
    document.querySelector("div").style.display = "block";
});

<div>blah blah blah</div>
<button>Show</button>

LIVE DEMO: http://jsfiddle.net/DerekL/p78Qq/

Comments