Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.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
Javascript 如何在';李';是否将鼠标悬停在上方并添加一个未悬停的类?_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何在';李';是否将鼠标悬停在上方并添加一个未悬停的类?

Javascript 如何在';李';是否将鼠标悬停在上方并添加一个未悬停的类?,javascript,jquery,html,Javascript,Jquery,Html,当将鼠标悬停在列表上时,如何添加一个类,并且还需要将另一个未悬停的类添加到列表中 我需要隐藏的元素,这是没有悬停的间距问题 下面是我的代码: $('#menu').on('mouseover', '> li', function(e) { # attach hover event to the menu, and check which LI you are hovering if (!$(this).hasClass('.current)')) { $('

当将鼠标悬停在列表上时,如何添加一个类,并且还需要将另一个未悬停的类添加到列表中

我需要隐藏的元素,这是没有悬停的间距问题

下面是我的代码:

$('#menu').on('mouseover', '> li', function(e) {
    # attach hover event to the menu, and check which LI you are hovering
    if (!$(this).hasClass('.current)')) {
        $('.current', '#menu').removeClass('active');
    }
}).on('mouseout', '> li', function (e) {
    if (!$(this).hasClass('.current)')) {
        $('.current', '#menu').addClass('active');
    }
});

通过你的问题,我只明白这一点,如果需要的结果是其他的,请让我知道

$(文档).ready(函数(){
$('li')。悬停(函数(){
$(“li”).addClass(“未覆盖”)
$(this.addClass('悬停')
},函数(){
$(this.removeClass('悬停')
$(“li”).removeClass(“未覆盖”)
});
});
。没有发现{
颜色:红色;
}
.盘旋{
颜色:绿色;
字体大小:22px;
}

  • 项目1
  • 项目2
  • 项目3
  • 项目4

也发布您的HTML,请制作一个片段。它太大,无法发布。你能从我已经提供的网站上查一下吗?