Skip to content

Instantly share code, notes, and snippets.

@oriadam
Created October 20, 2019 16:24
Show Gist options
  • Save oriadam/bad7bc21ccfb57e3eba2d0ddf25c3269 to your computer and use it in GitHub Desktop.
Save oriadam/bad7bc21ccfb57e3eba2d0ddf25c3269 to your computer and use it in GitHub Desktop.
add jQuery functionality `onAndNow` to add event listener and execute it once.
// call the handler now and on events
jQuery.fn.extend({
onAndNow: function(events, func) {
// TODO: Support the data object
return this.each(func).on(events, func);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment