I understand the difference between Live and Bind but when should I use use .bind()
over a \'standard\' event method as shown below.
Are there any key differ
They're effectively the same. However, using bind()
allows you to make use of namespaced events. This is especially useful when writing plugins.
They are the same. See here
in "bind" you can use multiple events
$('#foo').bind('mouseenter mouseleave', function() {
$(this).toggleClass('entered');
});
I use the explicit methods when available. I use the bind when a method isn't available like for window.onbeforeunload
The other time to use bind is if your are developing and switching between "live" and "bind".
use .bind
when you want to bind to "event.namespace"
Actaully almost always use .bind
and almost always use namespaces.