首页 > 技术文章 > $(...).live is not function

myzy 2016-11-08 12:09 原文

项目中引入了一个插件,但是调用的时候就报了$(...).live is not function

上网搜索了一下live方法在1.9中被删除了,因为平时自己用的时候就用on的方法,没用过live,所以对这个还不算熟悉。上代码

原代码:

$("li.select",_SELF).live("mouseover",function(){
                    $(this).find("div").show().animate({"opacity":options.setTitle.opacity },100);
                    $(this).find("b").show().delay(100).stop().animate({"height":textHeight,"opacity":options.setTitle.opacity},150);
                    return false;
                })

改完后的

    $("li.select",_SELF).on("mouseover",function(){
                    $(this).find("div").show().animate({"opacity":options.setTitle.opacity },100);
                    $(this).find("b").show().delay(100).stop().animate({"height":textHeight,"opacity":options.setTitle.opacity},150);
                    return false;
                })

相对应的1.9中被移除的方法都在这里哟 http://jquery.com/upgrade-guide/1.9/#live-removed

 

推荐阅读