FAQ Accordion made using SASS, mobile first and JS.

Solution retrospective
How should I implement faq expanding differently? I think that my solution is really messy.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @joanpujol
First of all, great-looking solution!
On the JS side, one way to simplify your code would be to use a click listener for each item that toggles an active class for that item.
faqItems.forEach(item => { item.addEventListener("click", () => { item.classList.toggle("active"); }); });
I hope it helps.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord