<div class="hidden-div">
<button onClick="toggleFunction()"> Click Me to see magic </button>
</div>
<div id="another-div">
Visible sometimes invisible div
</div>
</div>
div.hidden-div {
width: 100%;
margin: 50px auto;
text-align: center;
}
#another-div{
width: 300px;
height: 100px;
margin: 50px auto;
text-align: center;
font-size: 2em;
padding-top: 20px;
border-radius: 150px;
background-color: blue;
}
function toggleFunction(){
var toggle = document.getElementById("another-div");
if (toggle.style.display === "none") {
toggle.style.display ="block";
} else {
toggle.style.display ="none";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.