I am trying to code a burger menu that will change symbol from "-" to "x" on click and also show menu.
I'm done with the first part. The symbol is changed / toggled on click but I can't figure out how to display the menu.
This is working code I have
const menuButton = document.querySelector(".menu-button");
let showMenu = false;
menuButton.addEventListener("click", toggolmenu);
//function
function toggolmenu() {
if (!showMenu) {
menuButton.classList.add("close");
showMenu = true;
} else {
menuButton.classList.remove("close");
showMenu = false;
}
}
What I need to do is that when you click on ".menu-button" it will change from this:
<div class="menu-body">...</div>
to this:
<div class="menu-body show-menu-body">...</div>
Any ideas? Thank you in advance for your time