@filipjuszczak
Posted
Hi!
I would implement a function that removes the active
class from all other buttons than the clicked one. It would improve user experience, as now it's unsure which button was clicked last.
For buttons, I would add a custom data-value
attribute and assign a corresponding value to it, like this:
<button id="5-rating" class="rating-btn" type="button" data-value="5">5</button>
You could access that information like this:
function ratingBtnClicked(e){
if(e.target.classList.contains("rating-btn")){
e.target.classList.toggle("active");
}
defaultScore = e.target.dataset.value;
}
Marked as helpful