Last active
January 17, 2021 08:20
-
-
Save fauzanmy/85306479efe96d0c0960622f01a14a6c to your computer and use it in GitHub Desktop.
Simple JS toggle sidebar 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
<script> | |
let burger = document.querySelector('.burger'); | |
let close = document.querySelector('.close'); | |
let sidenav = document.querySelector('#sidenav'); | |
// Burger click function | |
burger.addEventListener('click', function () { | |
sidenav.classList.add('active'); | |
}); | |
// Close click function | |
close.addEventListener('click', function () { | |
sidenav.classList.remove('active'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment