What's the difference between jQuery.bind() and jQuery.on()?

后端 未结 3 1458
情话喂你
情话喂你 2020-12-06 05:27

And why is .on() now preferred in jQuery 1.7?

3条回答
  •  有刺的猬
    2020-12-06 05:56

    The old method was a bit messy - the difference between live(), delegate() and bind() was not clear. By making on() the function that handles attaching any event, regardless of whether it exists or not, it's just easier to work with.

    Before now, live() was a lot slower than the new on() function, hence why you had to choose between bind() and live().

提交回复
热议问题