简体   繁体   English

响应式多级导航错误

[英]Responsive Multi-level Navigation bug

I have a small issue with Micah Godbolt's Responsive Multi-level Navigation with active parent links . 我对Micah Godbolt的响应式多级导航(具有活动的父链接)有一个小问题。 It works great, except if the page loads slowly and you are hovering over the global nav, it can sometimes show two dropdowns. 效果很好,除非页面加载缓慢并且您将鼠标悬停在全局导航上,它有时会显示两个下拉菜单。 I'm guessing this is cause the javascript is not loading quick enough. 我猜这是因为javascript加载速度不够快。 Was wondering if anybody knew of an easy fix. 想知道是否有人知道一个简单的解决方法。

Here is the site I am using it on : http://library.buffalo.edu 这是我正在使用的网站: http : //library.buffalo.edu

If you refresh the page and hover over the links before the page fully loads, you see the problem screenshot of issue 如果刷新页面并在页面完全加载之前将鼠标悬停在链接上,则会看到问题屏幕截图

I assume you are hiding your dropdowns with javascript so you could add style="display: none" on your divs or css and use hover function. 我假设您使用JavaScript隐藏了下拉菜单,因此可以在div或CSS上添加style="display: none"并使用悬停功能。

you havent post your html but here's example 您还没有发布您的html,但这是示例

$(".parent").mouseover(function() {
    $(this).next("ul").show();
});

$(".parent").mouseleave(function() {
    $(this).next("ul").hide();
})

or you can replace those with one click function and use jQuery toggleClass to toggle a class that have display: block on it 或者您也可以将它们替换为一键式功能,然后使用jQuery toggleClass来切换具有display: block的类

Below function will work. 以下功能将起作用。 Try this 尝试这个

  $(".nav-global li").hover( function () { $(this).addClass("hover"); }, function () { $(this).removeClass("hover"); } ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM