Here is my solution with jQuery Mobile. I hope you will like it:
<style> .rated { background-color: yellow !important; } .rating a { border: 0px !important; } </style> <div class="rating" id="first"> <a href="#" data-role="button" data-inline="true" data-icon="star" data-vote="1" data-iconpos="notext"></a> <a href="#" data-role="button" data-inline="true" data-icon="star" data-vote="2" data-iconpos="notext"></a> <a href="#" data-role="button" data-inline="true" data-icon="star" data-vote="3" data-iconpos="notext"></a> <a href="#" data-role="button" data-inline="true" data-icon="star" data-vote="4" data-iconpos="notext"></a> <a href="#" data-role="button" data-inline="true" data-icon="star" data-vote="5" data-iconpos="notext"></a> </div> $(".rating a").on("vmouseover", function () { var id = $(this).parent().attr("id"); $("#" + id + ".rating a").each(function (i, v) { $(v).removeClass("rated"); }); $(this).prevAll().each(function (i, v) { $(v).addClass("rated"); }); $(this).addClass("rated"); $("#" + id).data("vote", $(this).data("vote")); });
https://jsfiddle.net/lgrillo/cz7z479j/
L. grillo
source share