Show / hide HTML element
html
JavaScript
<button onclick="toggleElem(event)">hide</button>
<div style="height: 100px; width: 100px; background-color: red;" id="block"></div>
<script>
function toggleElem(e) {
if (e.target.innerText != "show") {
document.querySelector("#block").style.display = "none";
e.target.innerText = "show";
} else {
document.querySelector("#block").style.display = "block";
e.target.innerText = "hide";
}
}
</script>