Apolo Radomer Apolo Radomer - 4 months ago 23
CSS Question

Hide and Unhide div with the same button

I am using a code that unhides a hidden div.


<div id="unhide" style="display:none;">DUMMY TEXT</div>

<button id="expand" name="expand">Show The Div</button>


document.getElementById("expand").addEventListener("click", function()
document.getElementById('unhide').style.display = "block";

How can I make the same button hide the div after clicking it again? Is it possible to alter the code I am using now?


use toggle to simple hide and unhide div

$("#expand").click(function() {