Created
September 9, 2020 06:40
-
-
Save wpflames/2e0d45affa409021ddd5ea2fe94bf12a to your computer and use it in GitHub Desktop.
JavaScript add class / remove class 2
This file contains hidden or 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 menuBtn = document.querySelector('.menu-btn'); | |
| let menuOpen = false; | |
| menuBtn.addEventListener('click', () => { | |
| if(!menuOpen) { | |
| menuBtn.classList.add('open'); | |
| menuOpen = true; | |
| } else{ | |
| menuBtn.classList.remove('open'); | |
| menuOpen = false; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment