I'm making a loop that returns several items, I have a Favorite button that when hover it runs a toggleClass to change the icon, but it only does that in the first item of the loop, can someone help me ?
<div class="favoriteButton" id="favoriteButton">
<i id="favoriteIcon" class="far fa-2x fa-heart"></i>
</div>
jQuery code:
// Favorite Icon
$("#favoriteIcon").hover(() => {
$("#favoriteIcon").toggleClass("far fas");
});
Loop:
for ($i = 0; $i < count($vehicles); $i++) {
echo '<div class="favoriteButton" id="favoriteButton">
<i id="favoriteIcon" class="far fa-2x fa-heart"></i>
</div>';
}