-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
18 lines (16 loc) · 790 Bytes
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(() => {
const menuBtnOpenRef = document.querySelector("[data-menu-button-open]");
const menuBtnCloseRef = document.querySelector('[data-menu-button-close]');
const mobileMenuRef = document.querySelector("[data-menu]");
menuBtnOpenRef.addEventListener("click", () => {
const expanded =
menuBtnOpenRef.getAttribute("aria-expanded") === "true" || false;
menuBtnOpenRef.setAttribute("aria-expanded", !expanded);
mobileMenuRef.classList.toggle("is-open");
});
menuBtnCloseRef.addEventListener('click', () => {
const expanded = menuBtnCloseRef.getAttribute('aria-expanded') === 'true' || false;
menuBtnCloseRef.setAttribute('aria-expanded', !expanded);
mobileMenuRef.classList.toggle('is-open');
});
})();