Design comparison
SolutionDesign
Solution retrospective
What challenges did you encounter, and how did you overcome them?
couldn't get the minus icon to show but i ended up getting it right. i used the details[open] .minus-icon{ display: block;} and it worked.
What specific areas of your project would you like help with?i want to include Javascript so that it only opens one Q and A at a time. if you know how to do that, please assist 🙏
Community feedback
- @MahmoodHashemPosted 4 months ago
Hello there
Congratulations on successfully finishing the challenge!
- You may already be aware that the FAQ section should function as an accordion, where opening one question hides the others. This can be achieved by adding a click event listener to the summary element of each details element. Inside the event listener, iterate through all the details elements and remove the open attribute from any details element that is not the one currently clicked.
Revised JavaScript code:
const details = document.querySelectorAll('details'); details.forEach((detail) => { detail.querySelector('summary').addEventListener('click', () => { details.forEach((d) => { if (d !== detail) { d.removeAttribute('open'); } }); }); });
Hope that's helpful!
Keep up the great work!
Marked as helpful0@doniecodesPosted 4 months ago@MahmoodHashem Hie. Thank you so so much for that one hey 😍 it did work.
1
Please log in to post a comment
Log in with GitHubJoin 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