【问题标题】:Plugging in jQuery HoverIntent for Sliding Panel为滑动面板插入 jQuery HoverIntent
【发布时间】:2010-02-03 23:58:00
【问题描述】:

我运行以下代码来创建一个下拉手风琴,当 div "#top_mailing" 悬停时显示隐藏的 div "#top_mailing_hidden"。问题是,当我通过鼠标移出然后再次鼠标悬停来中断动画时,它会中止动画并搞砸。

我有以下代码:

//Top Mailing List Drop down animation
$(document).ready(function () {

$('#top_mailing')
.bind("mouseenter",function () {
    $("#top_mailing_hidden").stop().slideDown('slow');
})
.bind("mouseleave",function () {
    $("#top_mailing_hidden").stop().slideUp('slow');
});

});

Brian Cherne 的插件说调用 hoverIntent 函数如下(其中 'makeTall' 和 'makeShort' 是定义函数:

$("#demo2 li").hoverIntent( makeTall, makeShort )

我认为我得到的行为的最佳解决方案是使用 Brian Cherne 的“HoverIntent”jQuery 插件。问题是我不知道如何/在哪里将代码插入到上面来调用 HoverIntent 插件。它说要调用“.hoverIntent”而不是 .hover 但我的代码使用的是 .bind("mouseEnter"... 有人请帮忙!

【问题讨论】:

    标签: jquery binding hoverintent


    【解决方案1】:

    您仍然可以通过 hoverIntent 使用匿名函数:

    $('#top_mailing').hoverIntent(function () {
       $("#top_mailing_hidden").stop().slideDown('slow');
     }, 
     function () {
       $("#top_mailing_hidden").stop().slideUp('slow');
    });
    

    【讨论】:

    • 好的,按照你写的完全插入代码我什么也没得到。动画根本不使用该代码运行。我需要你在上面的代码中删掉的“ .bind("mouseenter", function " 位吗?
    • 您根本不需要绑定....但请确保您在页面中的 jQuery 之后包含了 hoverIntent 插件(jquery.hoverintent.jsjquery.hoverintent.minified.js 文件)。跨度>
    • 得到它的工作,不知道是什么问题。我已经插入了 jquery 和 hoverIntent。作品!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    • 1970-01-01
    相关资源
    最近更新 更多