Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive Rating Component

@ClementBartholome

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

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

@VCarames

Posted

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 a button 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 helpful

1

@ClementBartholome

Posted

Thanks a lot for this feedback ! I'll look back into it 👍

0

Please log in to post a comment

Log in with GitHub
Discord logo

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