delegate() and live() both become on() in jQuery 1.7

jQuery 1.7 replaces bind(), live() and delegate() with a single method. Whether on() binds directly or delegates is decided by one thing: whether a selector was passed as the second argument.

// 1.6 and earlier
$('#orders a.cancel').live('click', cancelOrder);
$('#orders').delegate('a.cancel', 'click', cancelOrder);

// 1.7
$('#orders').on('click', 'a.cancel', cancelOrder);   // delegated
$('#orders a.cancel').on('click', cancelOrder);      // direct

Note that the argument order is reversed from delegate() — event type first, then selector — which is the detail that breaks a mechanical find-and-replace. live() is deprecated rather than removed, and deserves to be: it always attached at document, so every click anywhere on the page was tested against every live selector, and it could not be used at all with an event that does not bubble. Delegating from the nearest container that exists at page load gives the same benefit without either problem. The one condition is that the container has to exist when on() runs — delegation only rescues the descendants, not the element you bound to.