forked from fossceal/UNRAVEL-25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (21 loc) · 854 Bytes
/
index.js
File metadata and controls
24 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const hamburger = document.getElementById("hamburger");
const cartoonMenu = document.getElementById("cartoonMenu");
hamburger.addEventListener("click", () => {
hamburger.classList.toggle("active");
cartoonMenu.classList.toggle("show");
});
document.querySelectorAll(".cartoon-menu a").forEach(link => {
link.addEventListener("click", () => {
document.querySelectorAll(".cartoon-menu a").forEach(l => l.classList.remove("active"));
link.classList.add("active");
hamburger.classList.remove("active");
cartoonMenu.classList.remove("show");
});
});
// Close menu when clicking outside
document.addEventListener("click", (e) => {
if (!cartoonMenu.contains(e.target) && !hamburger.contains(e.target)) {
hamburger.classList.remove("active");
cartoonMenu.classList.remove("show");
}
});