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?
1 Answer
Do this:
#sddm li:hover,
#sddm li:hover a,
#sddm li a:hover {
background: #fff; color: #000;
}
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.
4 Comments
Stephen P
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.Jared Farrish
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.
:)Jared Farrish
@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.Stephen P
Mine too, thus "IIRC" - our IE6 traffic is now 0.05% and those are all probes from China.
:hoveron the containingli.