I have this code with the click()
function and it works:
$(document).ready( function() {
$('.rate .fa-star').click( function() {
alert('Clicked!');
});
});
However this code with the on()
function doesn't work and I don't know why
$(document).ready( function() {
$('body').on('click', '.rate .fa-star', function() {
alert('Clicked!');
});
});
Any idea what could be the problem? In the console I don't see any errors at all.
UPDATE:
I have this line of code somewhere else and when I comment it the on()
works as well:
$(".rate i.fa-star").click(function(e) { e.stopPropagation(); });
The problem is, I need this line for another functionality on my site. So, any idea how to make on()
work with this line of code like the click()
is working now?