3

I'm using the jQuery Simple Drop-Down Menu Plugin from http://javascript-array.com/scripts/jquery_simple_drop_down_menu/

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 timeout 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();
   jsddm_close();
   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;}}

$(document).ready(function()
{  $('#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?

2
  • you want to make red color tab as blue color ? Commented Jun 28, 2011 at 17:39
  • No, I want to make the tab I hover red like the dropdown. Then when the dropdown disappears, i want to make it blue again. Commented Jun 28, 2011 at 17:41

2 Answers 2

2

Update your style sheet with this :

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

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

See the Demo :

http://jsfiddle.net/rathoreahsan/evcL2/2/

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

2 Comments

Thanks that's neat! Please note the timeout js function I mentioned in my post. The plain css method works but the dropdown menu remains visible longer because it uses timeout so I must implement the css change in jquery
That's neat! +1 for using jsfiddle.
2

Just add these lines to css

#jsddm li a:hover
{   
background: #8EA344
}

put any color in the background you want.

2 Comments

Thanks but it should remain that color when you hover on the dropdown as well. For this reason I'm trying to modify the jquery.
See the answer I gave you. Update that styles in your current style sheet. Thanks!

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.