Design comparison
Community feedback
- @MasonBoomPosted about 2 years ago
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-1182Posted about 2 years ago@MasonBoom Thanks it's really a very helpful for me
1@Mayur-1182Posted about 2 years ago@MasonBoom Can you give me some tips how i can improve my css ??
0@Mayur-1182Posted about 2 years ago@MasonBoom Can you give me some tips how i can improve my css ??
0@MasonBoomPosted about 2 years ago@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 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