【问题标题】:Hover not working with jQuery Tools - jQuery [duplicate]悬停不使用 jQuery 工具 - jQuery [重复]
【发布时间】:2011-11-04 13:57:49
【问题描述】:

可能重复:
Hover not working with jQuery Tools - jQuery

当我将jQuery Tools 添加到我的页面时,链接上的悬停效果不起作用。没有它,它可以工作。

<script src="jquery.js"></script>
<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
<script src="jquery.color.js"></script>
<script>
$(function() {
    $(".header").live({ 
        mouseenter: function() {
            $(this).animate({color: "black"}, 400);
        }, 
        mouseleave: function() {
            $(this).animate({color: "white"}, 400);
        }
    });
});
</script>

另一个问题:jQuery Tools 工具提示是否适用于 jQuery live?

呃,我不认为你们理解它..当我不添加时它会起作用:

<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>

【问题讨论】:

  • 哪个浏览器版本和哪个版本的jQuery?我不会推荐 jQuery 工具作为任何可行的长期解决方案。它已经有大约一年没有更新了(从 jQuery 1.4.2 开始),在较新的浏览器(IE9)上存在问题,需要大量的手动标记,它没有得到很好的支持,开发人员显然已经失去了兴趣。

标签: jquery hyperlink hover jquery-animate jquery-tools


【解决方案1】:

问题是您用于 .live 的语法在 jQuery 1.4.2 中不起作用,它是在 jquery 1.4.3 中添加的。尝试以这种方式绑定:

<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
<script src="jquery.color.js"></script>
<script>
$(function() {
    $(".header").live('mouseenter mouseleave',function(e){ 
        $(this).animate({color: e.type === "mouseenter" ? "black" : "white" }, 400);
    });
});
</script>

编辑

此外,jquery 工具正在覆盖您原来的 jquery 脚本包含,这就是我省略它的原因。

【讨论】:

    猜你喜欢
    • 2011-11-02
    • 2016-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多