1

I have this fiddle: http://jsfiddle.net/tatygrassini/tZBXe/

Horizontal dropdown menu with a 1 level deep submenu. All menu links with :hover styles.

Once parent clicked, submenu slides down, you hover out, submenu hides back, OK so far.

I want to give the parent Add/Remove my CSS class a CSS class (.focus), when clicked to change its background color to fake a "focus" state.

In the jsfiddle, when you click on the Add/Remove my CSS class, you'll see it changes its background-color to red for a second, this is because of the :active CSS style.
So, even when you hover on the submenu links, the parent link remains in "focus" state, but, when you hover out, the "focus" CSS class will be removed to achieve its normal state CSS.

0

1 Answer 1

2

here's an updated code: http://jsfiddle.net/manuel/tZBXe/2/ I've added

$(this).addClass("focus");

and in the hover function

$("a", this).removeClass("focus");
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.