Multiple events calling same functions in jquery

This question already has an answer here:

  • jQuery multiple events to trigger the same function 10 answers

  • 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.

    链接地址: http://www.djcxy.com/p/96914.html

    上一篇: 2事件处理程序调用一个jQuery方法

    下一篇: 多个事件在jquery中调用相同的函数