jQuery下拉菜单问题 [英] jQuery Dropdown Menu Question

查看:83
本文介绍了jQuery下拉菜单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的下拉菜单中遇到一些问题。代码:
http://jsfiddle.net/xY2p6/1/ p>

很简单我只是没有得到,但你可以看到它不能正常工作。我不知道如何将下拉菜单的隐藏链接到用户悬停菜单链接时,而不是实际的下拉菜单。



任何想法? p>

解决方案

由于您的菜单在同一个< li> 请直接将悬停悬停在其上,如下所示:

  $(function(){
$(dropdown ).hover(function(){
$(this).children(div.sub-menu)。slideDown(200);
},function(){
$ ).children(div.sub-menu)slideUp(200);
});
});

您可以在这里试试 ,甚至更简单, .slideToggle() ,如下所示:

  $(function(){
$(dropdown)。hover (){
$(this).children(div.sub-menu)。slideToggle(200);
});
});

您可以在这里试试


Having some issues with my dropdown menu. Code here: http://jsfiddle.net/xY2p6/1/

Something simple I'm just not getting, but as you can see it's not functioning correctly. I'm not sure how to link the hiding of the dropdown to when the user hovers off of the menu link, rather than the actual dropdown.

Any ideas?

解决方案

Since your menu is inside the same <li> you can just attach the hover to it directly, like this:

$(function() {
    $(".dropdown").hover(function() {
        $(this).children("div.sub-menu").slideDown(200);
    }, function() {
        $(this).children("div.sub-menu").slideUp(200);
    });
});​

You can give it a try here, or even simpler with .slideToggle(), like this:

$(function() {
    $(".dropdown").hover(function() {
        $(this).children("div.sub-menu").slideToggle(200);
    });
});​

You can give it a try here.

这篇关于jQuery下拉菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆