I've seen two different ways to aproach it:
$('#element').on('click', function(){
/* do stuff */
});
Or:
$('#element').click(function(){
/* do stuff */
});
which is the correct/better way?
I've seen two different ways to aproach it:
$('#element').on('click', function(){
/* do stuff */
});
Or:
$('#element').click(function(){
/* do stuff */
});
which is the correct/better way?
.On() function was introduced in Jquery 1.7, it is better and more preferred method to call the event. whereas if you are looking for backward compatibility then choose the other one.