开发者

Need JS to keep the hover link active

开发者 https://www.devze.com 2023-02-25 13:56 出处:网络
I have a dropdown menu and i need help getting the hover link to stay active when i hover over it so it blends with the dropdown.

I have a dropdown menu and i need help getting the hover link to stay active when i hover over it so it blends with the dropdown.

I have put th开发者_StackOverflow社区e code on JSF

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

Thanks


You can fix it by changing this:

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

to this:

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

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


Add a class to the element you are hovering over in the hover function and then remove it when you exit. The class should have the same style has the hover style:

$(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");
    });
  });
});

Then define .hoverstyle.

0

精彩评论

暂无评论...
验证码 换一张
取 消