1

これがテストサイトのリンクです。サブメニューリンクを表示するという問題が発生しました。

そのナビゲーションバー「なぜストックホルム」にカーソルを合わせると、サブメニューも表示され、サブメニューにカーソルを合わせると、正常に機能しているので、間違ったことをしていることに感謝します。

(function($){

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

    //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();
            });
        }
    });
})(jQuery);
4

1 に答える 1

1

children()の代わりに使用する必要がありfind()ます。使用すると、セレクター内のfind('ul')すべてが使用されます。ul

これがjsFiddleの動作です。

        //show subnav on hover
        $(this).mouseenter(function() {
            $(this).children("ul").stop(true, true).slideDown();
        });

        //hide submenus on exit
        $(this).mouseleave(function() {
            $(this).children("ul").stop(true, true).slideUp();
        });
于 2013-01-30T00:10:21.573 に答える