I found two great articles talking about the new function .on(): jquery4u.com, elijahmanor.com.
Is there any way where the .bind() still is better to use than .on()?
For example, I have a sample code that look like this:
$("#container").click( function( e ) {} )
You can note that I just have one item retrieved by the selector and in my case, the <div> named #container already exists when my page was loaded; not added dynamically. It’s important to mention that I use the latest version of jQuery: 1.7.2.
For that sample, should .on() be used instead of .bind() even if I don’t use the other features provided by the .on() function?
Internally,
.bindmaps directly to.onin the current version of jQuery. (The same goes for.live.) So there is a tiny but practically insignificant performance hit if you use.bindinstead.However,
.bindmay be removed from future versions at any time. There is no reason to keep using.bindand every reason to prefer.oninstead.