Menu 在mousemove–上显示菜单;保持鼠标悬停

Menu 在mousemove–上显示菜单;保持鼠标悬停,menu,hover,hide,show,mousemove,Menu,Hover,Hide,Show,Mousemove,我有一个菜单,只显示在mousemove上。我希望它在鼠标悬停在菜单区域时保持显示 我现在有以下代码,不知道如何更改它以满足我的需要 var timer; $("html").on('mousemove', function() { $('nav').addClass('show'); try { clearTimeout(timer); } catch (e) {} timer = setTimeout(function() { $('nav').removeClass('sh

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

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

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

谢谢

可能不是最好的方式,但是通过使用以下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);
});