I am looking for a better way to bind multiple events to a single element in jQuery. I am trying to avoid writing multiple $(element).bind('event', ...) or $(element).event(...) statements.
Code
// old way
var textbox = $('input');
$(textbox).focus(function() { ... }
$(textbox).blur(function() { ... }
// new way
$(textbox).extend({
focus: function() {
...
},
blur: function() {
....
}
});
Unfortunately, this implementation is not working. Does anyone have a better suggestion? Thank you.
.on().