【问题标题】:Showing menu on mousemove – stay on mouseover在鼠标移动时显示菜单 - 停留在鼠标悬停上
【发布时间】:2018-06-29 18:36:29
【问题描述】:

我有一个仅在 mousemove 上显示的菜单。我希望它在鼠标悬停在菜单区域时保持显示。

我现在有以下代码,不知道如何更改它以满足我的需要。

var timer;
$("html").on('mousemove', function() {
$('nav').addClass('show');
try {
    clearTimeout(timer);
} catch (e) {}
timer = setTimeout(function() {
    $('nav').removeClass('show');
}, 2000);
});

谢谢

【问题讨论】:

    标签: menu hover hide show mousemove


    【解决方案1】:

    可能不是最好的方法,但使用这个 if 语句得到了结果:

    var timer;
    $("html").on('mousemove', function() {
    $('nav').addClass('show');
    try {
        clearTimeout(timer);
    } catch (e) {}
    
    if ($('nav:hover').length != 0) {
    }else
    timer = setTimeout(function() {
        $('nav').removeClass('show');
    }, 2000);
    });
    

    【讨论】:

      猜你喜欢
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 2013-03-14
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多