jQuery mouseoverIntent 不起作用,但悬停可以

2024-03-12

我有以下代码:

$(document).ready(function(){
    $(".yearInner").hide();

    $(".year", this).hover(
        function () {
            $(".yearInner", this).slideToggle();
        }
    );

});

它隐藏了带有 YearInner 类的 div,然后当包含带有 Year 类的 div 悬停在上面时,yearInner div 会打开。

工作正常,我想使用hoverIntent插件而不是悬停。与hoverIntent 根本不起作用。建议?

div结构参考:

<div class="year">
    2009  
    <div class="yearInner">
        More Info...
    </div>
</div>
<div class="year">
    2008
    <div class="yearInner">
        More Info...
    </div>
</div>

您需要拆分悬停/离开回调才能使用该插件,如下所示:

$(".year", this).hoverIntent(function () { 
   $(".yearInner", this).slideDown();
}, function() {
   $(".yearInner", this).slideUp("fast"); 
});

不知道为什么没有像 jQuery 在核心中那样的覆盖来接受在两种情况下运行的单个函数,但这就是修复。笔记:.slideToggle()仍然工作得很好,我只是添加了一些变化。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jQuery mouseoverIntent 不起作用,但悬停可以 的相关文章