I would like to know the difference between this:
$('#foo').click(function() {
alert('User clicked on "foo."');
});
and this
$('#foo').bind('click', function() {
alert('User clicked on "foo."');
});
(I read the documentation but I’m still not getting it).
$().click(fn)and$().bind('click', fn)are identical at first sight, but the$.bindversion is more powerful for 2 reasons:$().bind()allows you to assign one handler to multiple events, e.g.$().bind('click keyup', fn).$().bind()supports namespaced events – a powerful feature if you want to remove$().unbind)only certain event handlers that an element is bound to.