Skip to content

Commit

Permalink
Updated faq toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaillr committed Jul 24, 2024
1 parent 68a7fc1 commit c593843
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/js/faqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const questions = document.querySelectorAll('.question');
// Loop through each question element and add a click event listener
questions.forEach(question => {
question.addEventListener('click', () => {
// Toggle the 'active' class on the parent 'faqs' element
// Remove the 'active' class from all '.faqs' elements
document.querySelectorAll('.faqs.active').forEach(faq => {
faq.classList.remove('active');
});

// Toggle the 'active' class on the parent '.faqs' element of the clicked question
question.closest('.faqs').classList.toggle('active');
});
});

0 comments on commit c593843

Please sign in to comment.