Design comparison
SolutionDesign
Solution retrospective
responsive to any device display. but there are still many shortcomings, hopefully in the future it will be much better. any suggestions on my solution?
Community feedback
- @finng1337Posted about 2 years ago
Nice work Moeka! I looked up the code and saw one thing in the javascript to improve: What if instead of looping through the all questions and removing the active state, just saving index of the opened question? That could be little faster solution. Keep going!
Marked as helpful0@moe-kaPosted about 2 years agoThank you for the advice
is it true like this?
const answers = document.querySelectorAll('.faq'); var saveIndex = 0; answers.forEach(function (faq, index) { faq.addEventListener('click', function () { answers[saveIndex].classList.remove('active'); answers[index].classList.toggle('active'); saveIndex = index; }) })
but the toggle() doesn't work
0
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