Possible Duplicate:
Jquery event chaining
Traditionally we may write:
$("selector").click(function () {
});
but is it possible to chain events, something like so:
$("selector").click,keyu开发者_StackOverflow中文版p,keydown(function () {
});
I'm aware of the fact that I could write a function and reference that function in three seperate handlers, but this would be cleaner.
Use .bind()
$("selector").bind("keyup keydown click", function () {
});
For jQuery 1.7 and later, using the new API
.on() is more preferred
$("selector").on("keyup keydown click", function () {
});
精彩评论