add expanded menu

This commit is contained in:
isUnknown 2024-08-26 17:03:32 +02:00
parent b1ddfee49c
commit 049f11e011
9 changed files with 155 additions and 8 deletions

24
assets/js/script.js Normal file
View file

@ -0,0 +1,24 @@
document.addEventListener("DOMContentLoaded", () => {
// Functions
function expandNav() {
expandedNav.classList.add("open");
burgerBtn.setAttribute("aria-expanded", true);
closeNavBtn.setAttribute("aria-expanded", true);
}
function closeNav() {
expandedNav.classList.remove("open");
burgerBtn.setAttribute("aria-expanded", false);
closeNavBtn.setAttribute("aria-expanded", false);
}
// Variables
const burgerBtn = document.querySelector(".burger-btn");
const closeNavBtn = document.querySelector(".expanded-nav .close-btn");
const expandedNav = document.querySelector(".expanded-nav");
// Listeners
burgerBtn.addEventListener("click", expandNav);
closeNavBtn.addEventListener("click", closeNav);
});