Responsive FAQ Accordion Card

Solution retrospective
Hi everyone,
As my second solo javascript project, I struggled a bit on this one.
Do you have come advices to have less javascript in the project ?
Thanks !
Please log in to post a comment
Log in with GitHubCommunity feedback
- @vanzasetia
Hi, Raink31!
I recommend using the native HTML elements to create the accordions,
<summary>
and<details>
. These elements have already built-in toggle functionality. If you use them, you do not need to code the toggle functionality.Also, I recommend using
querySelectorAll
to select all the accordions. Then, useforEach
to target each element. Those can be used to create a functionality to only allow users to open one accordion panel at a time. This way, you don't have to select each individual element usingquerySelector
.I hope this 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