Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery、CSS和HTML创建的嵌套菜单_Jquery_Html_Css - Fatal编程技术网

使用jQuery、CSS和HTML创建的嵌套菜单

使用jQuery、CSS和HTML创建的嵌套菜单,jquery,html,css,Jquery,Html,Css,我正在尝试使用jQuery和多级嵌套创建导航栏 当我将鼠标悬停在主菜单上而不是只显示第一个列表时,所有嵌套列表都会显示出来,我不知道为什么 这是我的jQuery (function($) { // cache nav; var nav = $("#topNav"); //add indicators and hovers to submenu parents; nav.find("li").eac

我正在尝试使用jQuery和多级嵌套创建导航栏

当我将鼠标悬停在主菜单上而不是只显示第一个列表时,所有嵌套列表都会显示出来,我不知道为什么

这是我的jQuery

(function($) {

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

             //add indicators and hovers to submenu parents;
             nav.find("li").each(function() {
                 if (this.find("ul").length > 0) {  


                //   show subnav on hover
                     $(this).mouseenter(function() {
                         var ullist = $(this).find("ul");
                         ullist.stop(true, true).slideDown();

                         ullist.removeClass("sublinks");
                     });

                //   hide submenus on exit
                    $(this).mouseleave(function() {
                        var ullist = $(this).find("ul");
                        ullist.stop(true, true).slideUp();
                        ullist.addClass("sublinks");
                    });
                 }
            });

        })(jQuery);
还有我的css:

nav > ul > li > a > img {
width:60px;
  height:60px;
 }

nav ul ul ul
{
left:100px;
top:-1px;
}

.submenu{
display:none;
}

.sublinks li {
display:none;
}


.social li > a > img{
    width:40px;
height:40px;
}   
试试这个

(function($) {
             var nav = $("#topNav");
               nav.find("li").each(function() {
                 if ($(this).find("ul").first().length > 0) {  //find first ul only

                     $(this).mouseenter(function() {
                         var ullist = $(this).find("ul").first();  //find first ul only
                         ullist.stop(true, true).slideDown();

                         ullist.removeClass("sublinks");
                     });

                    $(this).mouseleave(function() {
                        var ullist = $(this).find("ul").first();  //find first ul only
                        ullist.stop(true, true).slideUp();
                        ullist.addClass("sublinks");
                    });
                 }
            });
        })(jQuery);

问题仍然存在。请参阅xetecx.comxa.com查看控制台错误。。我已经更新了代码。。尝试一下,并检查控制台中是否没有错误