导航菜单上的slideUp不起作用

时间:2012-07-17 07:35:30

标签: jquery html css

我有这个菜单: http://tabletest.orgfree.com/

我使用此功能:

function mainMenu(){
            (function($){

                //cache nav
                var nav = $("#nav");

                //add indicator and hovers to submenu parents
                nav.find("li").each(function() {
                    if ($(this).find("ul").length > 0) {
                        //$("<span>").text("^").appendTo($(this).children(":first"));
                        //show subnav on hover
                        $(this).mouseenter(function() {
                            $(this).find("ul").stop(true, true).slideDown();
                        });
                        //hide submenus on exit
                        $(this).mouseleave(function() {
                        $(this).find("ul").stop(true, true).slideUp();
                        //alert("this is an alert!");
                        });
                    }
                });
            })(jQuery);
            };

slideDown工作得很好但是slideUp不会工作,我不明白为什么,如果有人可以帮我这个。

感谢的。

1 个答案:

答案 0 :(得分:3)

它在你的CSS中。菜单放在视野之外。删除'left:-999em;'来自#nav li ul的声明:

#nav li ul {
    position: absolute;
    left: -999em; <--- REMOVE THIS
    height: auto;
    width: 14.4em;
    font-weight: normal;
    margin: 0;
}

另外,将其从内联样式中删除:

<ul style="left:-999em" id="matrix">

看到它正常工作:http://jsfiddle.net/c_kick/tsLPT/1/

相关问题