javascript - jQuery 菜单无法正常工作

标签 javascript jquery css drop-down-menu

我正在尝试让 jQuery 菜单正常工作,它会悬停在每个元素上。这是 fiddle code! .您可能会在结果中看到什么。当我悬停一个元素时,所有元素都会受到影响。我的错误在哪里?

这是javascript代码:

$(document).ready(function(){

    //Remove outline from links
    $("a").click(function(){
        $(this).blur();
    });

    //When mouse rolls over
    $("li").mouseover(function(){
        $(this).stop().animate({height:'200px'},{queue:false, duration:600, easing: 'easeOutBounce'})
    });

    //When mouse is removed
    $("li").mouseout(function(){
        $(this).stop().animate({height:'140px'},{queue:false, duration:600, easing: 'easeOutBounce'})
    });

});

如果还需要其他的请看fiddle code.

最佳答案

这是关于 CSS 的。更大的“li”扩展了你的“ul”。试试这个:

$(document).ready(function(){

    //Remove outline from links
    $("a").click(function(){
        $(this).blur();
    });

    //When mouse rolls over
    $("li").mouseover(function(){
        $(this).stop().animate({marginTop:'-60px'},{queue:false, duration:600, easing: 'easeOutBounce'})
    });

    //When mouse is removed
    $("li").mouseout(function(){
        $(this).stop().animate({marginTop:'0px'},{queue:false, duration:600, easing: 'easeOutBounce'})
    });

});​

http://jsfiddle.net/VpQkE/

关于javascript - jQuery 菜单无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10112228/

相关文章:

javascript - @media 在 react 中查询镭

javascript - HTML5/JS - 在 div 中显示多个文件输入

javascript - js中的相互斥力

jquery - 在悬停/鼠标悬停在 div 的特定区域上执行 jQuery 函数

html - 如何在容器 Bootstrap 4 中居中标签

jquery - 为什么基于 window.scrolltop 调整 css 可以一致工作,而 animate 却不能?

javascript - 我想关闭通过后端C#进程打开的firefox浏览器

javascript - 根据用户从下拉列表中的选择显示多个文本框

javascript - JavaScript 函数的目标数组

jquery - 单击按钮以 HTML 随机更改图像