-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.js
24 lines (19 loc) · 905 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener("DOMContentLoaded", () => {
const expandableLinks = document.querySelectorAll(".expandable");
expandableLinks.forEach(link => {
link.addEventListener("click", (e) => {
e.preventDefault(); // Prevent default link behavior
// Select the `.nested` sibling element
const nestedMenu = link.nextElementSibling;
// Log nested menu for debugging
console.log("Toggling visibility of:", nestedMenu);
if (nestedMenu && nestedMenu.classList.contains("nested")) {
nestedMenu.classList.toggle("visible");
link.classList.toggle("open");
// Update the icon
const icon = link.querySelector(".icon");
icon.textContent = nestedMenu.classList.contains("visible") ? "-" : "+";
}
});
});
});