CyberJunkie CyberJunkie - 2 months ago 39
CSS Question

jQuery dropdown menu CSS manipulation

I'm using the jQuery Simple Drop-Down Menu Plugin from

In their example, when you hover a menu item, a red dropdown box appears. I can't figure out how to make the main tab red as well while the dropdown is visible. It should remain red when you also hover on the dropdown and return to normal via timeout. The code uses a

function so I'll have to somehow implement it into that.

var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{ jsddm_canceltimer();
ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{ if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{ if(closetimer)
{ window.clearTimeout(closetimer);
closetimer = null;}}

{ $('#jsddm > li').bind('mouseover', jsddm_open)
$('#jsddm > li').bind('mouseout', jsddm_timer)});

document.onclick = jsddm_close;

I tried making a function for changing the background CSS and adding it to mouseover and mouseout, but it either changes the background for all menu tabs or nothing happens. Does anyone know a good solution?


Update your style sheet with this :

#jsddm li a:hover
    { background: #24313C }

    #jsddm li:hover > a
    { background: #24313C; display:block }

See the Demo :