I have a piece of code that on hover of another element insert's this code below.
<div class="star" id="1">
<div class="star" id="2">
<div class="star" id="3">
<div class="star" id="4">
<div class="star" id="5">
</div>
</div>
</div>
</div>
</div>
All I want to do is retrieve the ID of each DIV through javascript:
$(document).ready(function() {
$('.star').on(function(e){
e.stopPropagation();
var rating = $(this).attr('id');
alert(rating);
});
});
I've tried many ways of achieving this, this is the latest I've tried but I'm still having no luck! I'll be grateful of any help