Skip to content

Instantly share code, notes, and snippets.

@thirdj
Created October 11, 2013 00:52
Show Gist options
  • Save thirdj/6928024 to your computer and use it in GitHub Desktop.
Save thirdj/6928024 to your computer and use it in GitHub Desktop.
enter plugin
$.fn.enter = function(handler) {
return this.live("keypress", function(e) {
if (e.which == 13) {
e.preventDefault();
if (handler) {
$(this).bind("enter", handler);
$(this).trigger("enter");
$(this).unbind("enter");
}
}
});
};
/*
use
$('input').enter('handler');
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment