Event handler bind to an anonymous function vs named function

后端 未结 1 2159
一整个雨季
一整个雨季 2021-02-20 04:01

I know .on() exists with jQuery and .bind() should not be used in the future, considering that I have a version of jQuery greater than

1条回答
  •  长情又很酷
    2021-02-20 04:29

    There won't be any noticeable performance difference.

    One main difference is that with a named function you can also selectively unbind functions and not just all functions associated with an event type.

    Of course, this can also help you avoid code duplication.

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