【问题标题】:.stop() behaving oddly in Wordpress.stop() 在 Wordpress 中的行为异常
【发布时间】:2014-12-24 03:25:35
【问题描述】:

我正在开发一个 wordpress 投资组合网站。我在 codepen 中模拟了导航,它以我想要的方式工作。 http://codepen.io/ElaineM/pen/GgjgVE

    $(".menu-item").mouseover(function(){
        $(this).find("ul").stop().slideDown(500);
 });  
    $(".menu-item").mouseout(function(){
        $(this).find("ul").stop().slideUp(500);
    }); 

但是,当我在 Wordpress 中更新我的项目文件时,下拉子菜单不可见。当我从 jQuery 函数中删除 .stop() 时,下拉子菜单在鼠标悬停时可见,但动画会无限循环。 http://www.elainematthias.com/

我还让下拉子菜单与下面的代码一起使用,但我更喜欢使用 .slideDown() 和 .slideUp() 或类似的动画效果来柔化子菜单的外观。

$(".menu-item").mouseover(function(){
            $(this).find("ul").css("display","block")
        })
        $(".menu-item").mouseout(function(){
            $(this).find("ul").css("display","none")
        })

【问题讨论】:

    标签: jquery wordpress


    【解决方案1】:

    从子菜单<ul>中删除height: 1px;

    jQuery 函数的代码更少

    $(".menu-item").hover(function(){
            $(this).find("ul").stop().slideDown(500);
     },function(){
            $(this).find("ul").stop().slideUp(500);
        }); 
    

    工作演示http://jsfiddle.net/L05h18ue/4/

    【讨论】:

      猜你喜欢
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-30
      • 2017-09-18
      相关资源
      最近更新 更多