Skip to content

Instantly share code, notes, and snippets.

@jmar777
Created January 29, 2010 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmar777/290145 to your computer and use it in GitHub Desktop.
Save jmar777/290145 to your computer and use it in GitHub Desktop.
// Usage:
// $(context).delegate(selector,eventType[,eventData],handler);
// $(context).undelegate(selector[,eventType][,handler]);
jQuery.each({ delegate : "live", undelegate : "die" }, function(k, v) {
jQuery.fn[k] = function() {
var sel = Array.prototype.shift.apply(arguments), args = arguments;
return this.each(function() {
$.fn[v].apply($({ selector : sel, context : this }), args);
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment