JSFiddle - React, Tailwind, and code Playground
HTML
<button class="toggle">
toggle
</button>
<div id="nav" class="hidden">
element
</div>
CSS
.hidden {
display: none;
}
div {
margin-top: 10px;
}
JavaScript
document.addEventListener("DOMContentLoaded", function e() {
var n = function(e) {
document.getElementById("nav").classList.toggle("hidden")
};
document.removeEventListener("DOMContentLoaded", e);
var t = Array.prototype.slice.call(document.querySelectorAll(".toggle"), 0);
t.length && t.forEach(function(e) {
e.addEventListener("click", n)
})
})