Faq accordion using Javascript

Solution retrospective
This was my first project with Javascript so I am proud to pull that off. Next time, I will continue to define my responsive design and Javascript skills.
What challenges did you encounter, and how did you overcome them?Initially, I was not sure how to center the faq component with flexbox while still allowing the page length to grow as the accordion opens (because I had been using "height: 100vh;" on the parent in order to center containers). After doing some digging online, I discovered that I could use "min-height: 100vh;" to allow the parent to grow with the content.
What specific areas of your project would you like help with?Two things:
-
Toggling the plus/minus icons: the only way I could find to toggle the plus/minus icons on each faq was to write a separate function for each question. Otherwise, the function would only toggle the top icon regardless of which question you clicked on. Does anyone know of a more efficient way to do this?
-
I found that if I open and close the accordion repeatedly, the plus/minus icons eventually get out of sync. I would love to find a way to make my functions a little less breakable.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Camryn Tidsworth's solution.
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