Fix unexpected nav behaviour
parent
04f729729b
commit
95320141a0
@ -1,5 +1,15 @@
|
|||||||
document.getElementById("menu-button").addEventListener("click", function(){
|
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");
|
document.body.classList.toggle("noscroll");
|
||||||
this.getElementsByClassName("image")[0].classList.toggle("open");
|
element_button.getElementsByClassName("image")[0].classList.toggle("open");
|
||||||
document.getElementById("nav").classList.toggle("visible");
|
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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue