Bind function to multiple events of different elements at once

后端 未结 1 747
时光说笑
时光说笑 2020-12-12 00:49

I would like to bind a function to the mouseout event of my element, and bind the same function to the blur and c

相关标签:
1条回答
  • 2020-12-12 01:00

    You can't. Define your function beforehand:

    function eventHandler(event) {}
    

    and assign it separately:

    $('canvas').mouseout(eventHandler);
    $('body').bind('blur contextmenu', eventHandler);
    

    With .bind you can at least bind one event handler to multiple events.

    0 讨论(0)
提交回复
热议问题