• jquery TypeError: $(...).live is not a functio,动态添加class的点击事件处理


    jq版本更新后无live函数的处理.TypeError: $(...).live is not a function

    jquery live函数语法
    jquery版本更新, 发现一个问题: jq自带的live没有了.
    控制台下会有如下的提示:
    火狐: TypeError: $(...).live is not a function

    chrome: Uncaught TypeError: Object [object Object] has no method 'live' 


    网上的一个说法: 
    jQuery 1.9 较之前的版本做了很大的调整,很多函数都不被支持。
    例如 live(),die(),toggle(),sub(),$.browser 等等都已经被移除,完整的更新内容见 http://jquery.com/upgrade-guide/1.9/ (英文)。
     
    在不改变你网站代码的同时,要使用 1.9 之后的版本,你需要使用 jQuery Migrate(转移、过度),详见 http://blog.jquery.com/2013/01/31/jquery-migrate-1-1-0-released/ (英文)。
    Migrate 应该只是暂时性的。为了和 jQuery 保持同步,建议你从现在开始根据 1.9 的改变重写你网站的所有代码。
    所以之前你的代码如果是
    $("#ele").live("click", function() {
        //...
    });
    现在要写成
    $("#ele").on("click", function() {
        //...
    });
    动态生成的元素要使用 live,要写成
    $(document).on("click", "#ele", function() {
        //...
    });

  • 相关阅读:
    oracle语法
    cin.clear()、cin.sync()
    Intellij Idea Spring Boot 热部署
    navicat_premium_x64最新版安装说明
    激活navicat premium12
    时间戳Unix和时间之间的转换
    排序算法-- 大总结
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
    final
    static
  • 原文地址:https://www.cnblogs.com/Bouger/p/6122260.html
Copyright © 2020-2023  润新知