Check aria-expanded value instead of class name to toggle the attribute of navigation toggle button

This commit is contained in:
Helen Chong 2024-06-08 00:24:58 +08:00
parent ee4e82c268
commit 1bc88b6c95
1 changed files with 1 additions and 1 deletions

View File

@ -96,7 +96,7 @@
const showClass = "navbar__links--show"; const showClass = "navbar__links--show";
navbarLinks.classList.toggle(showClass); navbarLinks.classList.toggle(showClass);
if (navbarLinks.classList.contains(showClass)) { if (navbarToggle.getAttribute("aria-expanded") === "false") {
navbarToggle.setAttribute("aria-expanded", "true"); navbarToggle.setAttribute("aria-expanded", "true");
} else { } else {
navbarToggle.setAttribute("aria-expanded", "false"); navbarToggle.setAttribute("aria-expanded", "false");