You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
531 B
JavaScript
16 lines
531 B
JavaScript
let element_button = document.getElementById("menu-button");
|
|
let element_nav = document.getElementById("nav");
|
|
let nav_items = document.getElementById("nav").getElementsByTagName("a");
|
|
|
|
function toggle_menu() {
|
|
document.body.classList.toggle("noscroll");
|
|
element_button.getElementsByClassName("image")[0].classList.toggle("open");
|
|
element_nav.classList.toggle("visible");
|
|
}
|
|
|
|
element_button.addEventListener("click", toggle_menu);
|
|
|
|
for (i = 0; i < nav_items.length; i++) {
|
|
nav_items[i].addEventListener("click", toggle_menu);
|
|
}
|