0

I want to change the background color of a link with jQuery, the orginal CSS for the link is

#container ul li:hover ul li a{
    background: #FF0000
}

I'm trying the following jQuery code, but it does not seem to work.

jQuery('#container ul li:hover ul li a').css('background', '#FF0000');

I can set the css for the normal links, but its only causing problem with the link hover.

2 Answers 2

3

try this:

jQuery('#container ul li ul li a').hover(function(){
   $(this).css('background', '#FF0000');
})

or this :

jQuery('#container ul li').hover(function(){
   $(this).find("ul li a").css('background', '#FF0000');
})
Sign up to request clarification or add additional context in comments.

Comments

0

You could try it with the jquery hover function. http://api.jquery.com/hover/ And re-set the color.

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.