Multiple events calling same functions in jquery
This question already has an answer here:
You can define more than one event by separating them with a space.
$('selector').on('keyup mouseout click', function(){
// will be called commonly
});
You can use the above with bind
also. Also, you could create a separate function and pass it to each handler, but that is overkill, I suppose.
上一篇: 2事件处理程序调用一个jQuery方法
下一篇: 多个事件在jquery中调用相同的函数