2

I have a dropdown menu that works by Classic CSS hover

if you've opened the menu with a click event, i need the hover effect to be removed but i can't because you're still hovering over the menu the menu doesn't disappear until you hover off which isn't ideal. I also tried using .hide() but then that messes with CSS hover functionality.

Is there a way in jQuery to remove the CSS hover activation of an element?

 $("ul.nav > li").click(function(e) {
   var url = $(this).attr("url");
   $(this).css('background', '#bbb');
   if( url == 'logoutServlet') {
       $.get('logoutServlet');
       window.location = "/a";
   }else{
       $("#content").html('Loading...').load(url);
  }       
});
3
  • 1
    You cannot remove hover effect. Add a new class and add empty to its hover css. This quesion has an answer here stackoverflow.com/a/5069151/3639582 Commented Jun 17, 2014 at 9:19
  • are u having a class name hover?? Commented Jun 17, 2014 at 9:22
  • @ Don No i actually used classic hover method to show submenu on hover Commented Jun 18, 2014 at 9:38

1 Answer 1

0

Hover state is not a class, you should use CSS to change hover behavior of an element.

for example:

a.whatever { color: black; } /* Default state */
a.whatever:hover { text-decoration: none; color: black; } /* Hover state */

You can match hover state rules with other states behavior to make it look the same.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.