How To Build A Simple Star Rating System - Simon Ugorji | Tealfeed
Fri Mar 17 2023 19:21:51 GMT+0000 (UTC)
Saved by
@Anzelmo
document.addEventListener('DOMContentLoaded', function(){ (function(){ let sr = document.querySelectorAll('.my-star'); let i = 0; //loop through stars while (i < sr.length){ //attach click event sr[i].addEventListener('click', function(){ //current star let cs = parseInt(this.getAttribute("data-star")); //output current clicked star value document.querySelector('#output').value = cs; })//end of click event i++; }//end of while loop })();//end of function})
content_copyCOPY
https://tealfeed.com/build-simple-star-rating-system-swohq
Comments