【问题标题】:How can I keep active subnav visible when using fadeIn fadeOut for hover states使用fadeIn fadeOut 进行悬停状态时如何保持活动子导航可见
【发布时间】:2012-10-21 05:29:41
【问题描述】:

我被一些 jquery 卡住了,我在子导航的悬停状态上有淡入和淡出。

我的不足之处是,一旦您将鼠标悬停在活动状态上/下,子导航就会淡出,但我希望它保持可见。

jquery:

$("ul#main-nav li").hover(function() { //Hover over event on list item
$(this).find("span").fadeIn("slow"); //Show the subnav
    } , function() { //on hover out...
$(this).find("span").fadeOut("slow"); //Hide the subnav

我在 JF 上有我的代码:

http://jsfiddle.net/ByteMyPixel/g8W5Y/

【问题讨论】:

    标签: jquery menu fadein fadeout nav


    【解决方案1】:

    如果是活动项则退出淡出:

    $("ul#main-nav li").hover(function() { //Hover over event on list item
        $(this).find("span").fadeIn("slow"); //Show the subnav
    }, function() { //on hover out...
        if($(this).hasClass('active')) {
              return;   
        }
        $(this).find("span").fadeOut("slow"); //Hide the subnav
    });
    

    【讨论】:

    • 这正是我所需要的!谢谢狄奥多斯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多