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

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

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

3条回答
  •  旧巷少年郎
    2020-12-06 05:59

    The MAIN difference is that .bind requires the element (selector) exist AT THE TIME it gets attached, whereas .on does not have that requirement, and .on frankly has better/more elegant syntax in my opinion. See the documentation first paragraph http://api.jquery.com/bind/

提交回复
热议问题