-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
26 lines (23 loc) · 911 Bytes
/
main.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
const faqDiv = document.querySelector('.faq-list');
// Add event listener to the FAQ list container
faqDiv.addEventListener('click', (event) => {
let target = event.target;
let content = event.target.parentElement.parentElement.nextElementSibling;
if (event.target.className == "plus-icon") {
collapseFAQ();
target.src = "assets/cancel-icon.png";
target.className = "cancel-icon";
content.classList.add('show-faq-body');
} else if (event.target.className == "cancel-icon") {
target.src = "assets/plus-icon.png";
target.className = "plus-icon";
content.classList.remove('show-faq-body');
}
});
// Function to collapse all FAQ items
function collapseFAQ() {
faqDiv.querySelectorAll('.faq-body').forEach((faqItem) => {
faqItem.classList.remove('show-faq-body');
faqItem.previousElementSibling.querySelector('.faq-icon img').src = "assets/plus-icon.png";
});
}