I want to toggle element visibility. Currently, when clicking button1, it's just hiding, and not toggling.
This is my code and I want to know why it doesn't show button2 after hiding it.
function fonk10() {
var x = document.getElementsByClassName("eben")[0];
if (x.style.cssText === "display:none") {
x.style.cssText = "display:inline-block";
} else {
x.style.cssText = "display:none";
}
}
.eben{
background:green;
padding:5px;
display:inline-block;
}
#eben{
background:green;
padding:5px;
display:inline-block;
}
<div id="eben" onclick="fonk10()">BUTTON1</div>
<div class="eben">BUTTON2</div>