-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
44 lines (34 loc) · 1.41 KB
/
script.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// FAQ Accordion
document.addEventListener("DOMContentLoaded", () => {
const faqContainer = document.querySelector(".faq-content");
faqContainer.addEventListener("click", (e) => {
const groupHeader = e.target.closest(".faq-group-header");
if (!groupHeader) return;
const group = groupHeader.parentElement;
const groupBody = group.querySelector(".faq-group-body");
const icon = groupHeader.querySelector("i");
// Toggle Icon
icon.classList.toggle("fa-plus");
icon.classList.toggle("fa-minus");
// Toggle visibility of body
groupBody.classList.toggle("open");
// Close other open FAQ bodies
const otherGroups = faqContainer.querySelectorAll(".faq-group");
otherGroups.forEach((otherGroup) => {
if (otherGroup !== group) {
const otherGroupBody = otherGroup.querySelector(".faq-group-body");
const otherIcon = otherGroup.querySelector(".faq-group-header i");
otherGroupBody.classList.remove("open");
otherIcon.classList.remove("fa-minus");
otherIcon.classList.add("fa-plus");
}
});
});
});
document.addEventListener("DOMContentLoaded", () => {
const hamburgerButton = document.querySelector(".hamburger-button");
const mobileMenu = document.querySelector(".mobile-menu");
hamburgerButton.addEventListener("click", () =>
mobileMenu.classList.toggle("active")
);
});