开发者

Need JS to keep the hover link active

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜