JQuery jquery-1.7.1.min.js live() deprecated use on()

后端 未结 2 2059
小蘑菇
小蘑菇 2021-01-22 08:57

from jQuery website:

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.

with version 1.7.1 i

相关标签:
2条回答
  • 2021-01-22 09:20

    Converting code from using .live to .on isn't just a case of replacing the calls to .live with .on calls. They accept different arguments, and are called on different selectors. For example, the old syntax:

    $('a').live('click', function () {});
    

    With .on:

    $(document).on('click', 'a', function () {});
    

    This syntax gives you greater control and flexibility.

    I would recommend reading the documentation: http://api.jquery.com/on/

    And for information on converting to .on from .live: http://api.jquery.com/live/

    0 讨论(0)
  • 2021-01-22 09:25

    Specific to the code submitted, as per the ramblings above;

    Replace

    $(".toBeSaved [col=ISRC] input").on('change',function() {
    

    with

     $(document).on('change','.toBeSaved [col=ISRC] input', function() {
    
    0 讨论(0)
提交回复
热议问题