【问题标题】:jquery's live() is deprecated. What do I use now?jquery 的 live() 已弃用。我现在用什么?
【发布时间】:2012-02-23 22:02:26
【问题描述】:

我在 jquery 文档中看到 live() 已被弃用。有直接替换功能吗?

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:

    $(document).on('event', 'selector', function() {}); 替换 .live()

    $('selector').on('event', 'selector', function() {}); 替换 .delegate()

    $('selector').on('event', function() {}); 替换 .bind()

    【讨论】:

      【解决方案2】:

      当然:

      http://api.jquery.com/on/

      http://api.jquery.com/off/

      live() 的页面显示了如何转换为on()

      http://api.jquery.com/live/

      【讨论】:

        【解决方案3】:
        $('rootselector').on('click', 'selector', function(){
        });
        

        取自http://api.jquery.com/on/

        【讨论】:

          【解决方案4】:

          您可以查看 jquery 的所有已弃用功能,具体取决于它们的版本

          http://api.jquery.com/category/deprecated/

          希望对你有所帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2020-07-16
            • 2021-07-14
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多