Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Like jQuery's .one but runs only once, across multiple elements and/or event types.
* jQuery oneOnly - v0.1pre - 03/30/2011
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
$.fn.oneOnly = function( types ) {
var elems = this,
args =,
fn = args.pop();
function handler() {
elems.unbind(types, handler);
return fn.apply(this, arguments);
return this.bind.apply(this, args.concat(handler));

This comment has been minimized.

Copy link
Owner Author

cowboy commented Mar 30, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.