Adam Alberty• 105
@AdamAlberty
Submitted
How should I implement faq expanding differently? I think that my solution is really messy.
Looking to hire developers?
@joanpujol
@AdamAlberty
Submitted
How should I implement faq expanding differently? I think that my solution is really messy.
@joanpujol
Posted
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.