jQuery .live()和.on()之间有什么区别?

我看到有一个新的方法.on()在jQuery 1.7,替换.live()在早期版本。



Use of the .live() method is no longer recommended since later
versions of jQuery offer better methods that do not have its
drawbacks. In particular, the following issues arise with the use of

  • jQuery attempts to retrieve the elements specified by the selector before calling the .live() method, which may be
    time-consuming on large documents.
  • Chaining methods is not supported. For example, $("a").find(".offsite, .external").live( ... ); is
    not valid and does not work as expected.
  • Since all .live() events are attached at the document element, events take the longest and slowest
    possible path before they are handled.
  • Calling 07001
    in the event handler is ineffective in stopping event handlers
    attached lower in the document; the event has already propagated to
  • The .live() method interacts with other event methods in ways that can be surprising, e.g.,
    $(document).unbind("click") removes all click handlers
    attached by any call to .live()!

转载请明显位置注明出处:jQuery .live()和.on()之间有什么区别?