0

I have a problem in a jquery dropdown menu. In my example (link in the bottom) I want that when I hover the Submenu the color of the current menu item (item 2) stays in hover state (color white in example).

I want this in jquery/javascript and not css.

Link To Live Example with complete Code

Thanks

1 Answer 1

2
$("ul.submenu li a").css({'background-color': '#fdfa02'});
$("ul.submenu").css({'background-color': '#fdfa02'});
$("ul.submenu2").css({'background-color': '#fdfa02'});   
$('ul.submenu li a').css('color', '#00FF00');

//change the menu text color on mouse over
$('ul.menu li').hover(function () {    
     $(this).find("span:first a").css({color:'#FFFFFF'});    
},
function () {
    $(this).find("span:first a").css({color:'#000000'});  
});
Sign up to request clarification or add additional context in comments.

6 Comments

Could you tell me where you put the code ? In teory with this line of code if you hover the submenu the text in the menu stay white, but if you hover out the submenu, the text stays white, don't change to original state (black), but I could be wrong
"I want this in jquery/javascript and not css." :P
There you go, white text bug fixed
@Sbml: You are wrong! Make the code change inline -- it's clear to see where it should go, as other parts match up with your existing code -- and you will see it working.
@Sbml: Note that his .css change no longer applies just to the .hovered-only element, but to anything matching "span:first a" under it.
|

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.