What I want to do is that when I hover over a star, all previous ones have a "selected" class, I tried to use siblings together with each one and I almost got the result where I wanted it.
The result I want to get is something like this: JQUERY
$('.estrela').on({'mouseenter':function(){$(this).siblings().each(function(){$(this).removeClass("fa-star-o").addClass("fa-star");
});
}, 'mouseleave': function () {
$(this).removeClass("fa-star").addClass("fa-star-o");
}
});
HTML
<form>
<h5>1 - Quantas estrelas você recomenda?</h5>
<?php for ($i = 1; $i <= 5; $i++): ?>
<a href="#" class="estrela fa fa-star-o" data-estrelas="<?= $i; ?>"></a>
<?php endfor; ?>
</form>