1

I am trying to create a very simple javascript drop down menu. The menu works as intended except when I onmouseout the div that makes the dropped down div visible it is loses its background color. So when I am mousing over #m2 I want the #sddm li a:hover to remain active. Do I need jquery for this or can it be done in javascript?

http://jsfiddle.net/6ZzK2/

1
  • You might be able to put the :hover on the containing li. Commented Dec 13, 2011 at 1:18

1 Answer 1

2

Do this:

#sddm li:hover,
#sddm li:hover a,
#sddm li a:hover {
    background: #fff; color: #000;
}

http://jsfiddle.net/cdBZC/

That at least works in FF8.0. The only browser you might have a problem with is IE version 6/7, who may not support the :hover pseudo class on lis. I'm not sure.

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

4 Comments

IIRC IE6 only does :hover on <a> elements, but IE7 works fine. We do our (2-level) menus like this and dropped support for IE6 when we decided to go "pure-CSS" -- @Jonathan - no javascript or jquery required.
I wasn't sure, I was thinking it was only IE6. My memories of that albatross are beginning to be old and fuzzy, "walk both ways uphill in four foot snow"-type memories. Thank God. :)
@Jonathan - Also note that the #sddm li a:hover selector is probably superfluous; you can remove it and it won't have any effect, I think.
Mine too, thus "IIRC" - our IE6 traffic is now 0.05% and those are all probes from China.

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.