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

@beRajeevKumar

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


It is interactive rating project. I want to make it more functional but as a beginner this is only i build.So take a look and help me to make my code more efficient and make it more functional.

Community feedback

@davinaleong

Posted

Hi, instead of buttons, I suggest using radio buttons since they already have the ability to deselect the other choices when one choice is selected when they share the same name attribute.

Link the radio buttons to the labels via the for attribute. Hide the radio buttons and style the labels.

To style checked labels, you can to this:

input[type=radio]:checked + label { ... }

This will select the label immediately after the radio input.

For toggling the different views, I prefer to use data attributes as opposed to classes.

E.g. HTML: <section class="thanks" data-open>...</section>

Then you select the element like this in CSS:

.thank-you-section {
  display: none;
}

.thank-you-section[data-open] {
  display: block;
}

Then in your JavaScript, you can do this: thanks.setAttribute("data-open", true);

Marked as helpful

1

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