Created
October 17, 2019 15:08
-
-
Save francisrupert/341c58e6a233e08128fe4e0d88380fba to your computer and use it in GitHub Desktop.
js toggle menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toggleMenu = document.querySelector(".navigation button"); | |
const menu = document.querySelector(".navigation ul");; | |
toggleMenu.addEventListener("click", function () { | |
const open = JSON.parse(toggleMenu.getAttribute("aria-expanded")); | |
toggleMenu.setAttribute("aria-expanded", !open); | |
menu.hidden = !menu.hidden; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment