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

HTML,CSS ,JS

@Mayur-1182

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

@MasonBoom

Posted

Hello,

Although this project is very well done, I believe that there is always room for improvement.

I noticed that I was able to select more than one rating button at a time. A way to solve this issue is to loop through each of the buttons and have all of them change back to their original state before changing the desired button to orange. Here is the function that I used (I used React.js in my project)

const toggleButton = index => { const buttons = document.getElementsByClassName('button'); for (let i = 0; i < buttons.length; i++) { buttons[i].classList.remove('active'); } buttons[index].classList.add('active'); setRating(index + 1); }

and then from here you could do something like this:

rating_number[i].addEventListener("click",(i)=>{ toggleButton(i) })

0

@Mayur-1182

Posted

@MasonBoom Thanks it's really a very helpful for me

1

@MasonBoom

Posted

@Mayur-1182 no problem

0

@Mayur-1182

Posted

@MasonBoom Can you give me some tips how i can improve my css ??

0

@Mayur-1182

Posted

@MasonBoom Can you give me some tips how i can improve my css ??

0

@MasonBoom

Posted

@Mayur-1182 your css file looks just fine to me, I would just increase the size of the rating buttons slightly.

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