
Solution retrospective
I'm proud that I successfully implemented a cleaner and more dynamic solution using parentElement
and querySelector
for toggling content visibility based on user interaction. Next time, I would consider making the code more scalable by using classList.toggle()
and adding animation effects for a smoother UI.
One challenge was identifying the correct <p>
tag associated with each button click without relying on fixed indices. I overcame this by learning how to traverse the DOM using parentElement
and querySelector
to target elements dynamically and accurately.
I’d like help improving accessibility (e.g., keyboard navigation), adding transitions for better UX, and maybe refactoring the code further to make it reusable for a larger number of toggle elements.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @MarziaJalili
Bulletproof solution! 🎉
🌟 A tiny suggesteenoo?
✅ First, consider changing
<section>
to<main>
as every web page needs one <main> element to represent the main its content not a section, bro.✅ Second, you can wrap the toggle images within a <button> for keyboard a11y.
✅ Also, using grid is the cleanest way for centering:
display: grid; place-items: center;
Stay consistent and everything will become an open book! 😌
Marked as helpful
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