I have been searching around without finding an satisfying answer. What is the difference between the 2 following event-handlers.
$('#div').on('click', function(){
//do something
});
and
$('#div').click(function(){
//do something
});
I know that in the $('#div').on('click', function()
, you can send in more div or class-selectors in addition to 'click'
, but is that it?
I'd love to hear what else separates them, and if there are times where one is better to use than the other.
Thanks
click()
is the shorthand foron('click')
. That's it (in your use-case)..bind
have been deprecated in favor for.on
.click
documentation was updated to "This method is a shortcut for.on('click', handler)
"