需要JS保持悬停链接活动

Need JS to keep the hover link active

本文关键字:链接 活动 悬停 JS 需要      更新时间:2023-09-26

我有一个下拉菜单,我需要帮助让悬停链接保持活跃,当我悬停在它上面,所以它与下拉菜单混合。

我已经把代码放在JSF

http://jsfiddle.net/JmR87/2/

谢谢

你可以修改这个:

#nav-container li a:hover span {
    display: block;
    background-image: url(https://i.stack.imgur.com/sTqNy.gif);
    background-repeat: repeat-x;
}

:

#nav-container li:hover span {
    display: block;
    background-image: url(https://i.stack.imgur.com/sTqNy.gif);
    background-repeat: repeat-x;
    color: #000
}

见:http://jsfiddle.net/JmR87/5/

在悬停函数中为要悬停的元素添加一个类,然后在退出时将其移除。类的样式应该与hover样式相同:

$(function () {
  $('.dropdown, .dropdown2, .dropdown3').each(function () {
    $(this).parent().eq(0).hover(function () {
      $('.dropdown, .dropdown2, .dropdown3:eq(0)', this).show();
      $(this).addClass("hoverstyle");
    }, function () {
      $('.dropdown, .dropdown2, .dropdown3:eq(0)', this).hide();
      $(this).removeClass("hoverstyle");
    });
  });
});

则定义.hoverstyle