Design comparison
SolutionDesign
Solution retrospective
Not so easy challenge as I just started learning JavaScript. I struggled to find a way to change the background-color of the "onfocus" radio input. Hopefully my solution is fine.
I'd appreciate any feedback. Thank you !
Community feedback
- @VCaramesPosted over 1 year ago
Hey there! 👋 Here is some feedback to further improve your code:
- The
form
should only be wrapping ⚠️ the rating "buttons" and "submit" button.
- This is
<input type="submit" class="btn" value="SUBMIT" id="submitBtn"/>
outdated. Instead use abutton
element.
- This is not necessary. Your JS should NOT ❌ be doing the job of CSS. You can use the pseudo element
:checked
to indicate which "button" was selected. So
const label = document.querySelectorAll(".rating") label.forEach(i => { i.addEventListener("click", function () { label.forEach(i => i.classList.remove("active")) this.classList.add("active") }) })
If you have any questions or need further clarification, you can always check out my submission and/or feel free to reach out to me.
Happy Coding! 👾
Marked as helpful1@ClementBartholomePosted over 1 year agoThanks a lot for this feedback ! I'll look back into it 👍
0 - The
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