0

I have 2 div's one contains "clickable div" and other "nav_menu" which is menu. There is a mouseleave function implemented for "#clickable_div" my problem is when i hover over the menu it should not slideUp which is currently happening How can i fix this ?

Note : I'm using a small plugin for dropdown

JSFiddle - > http://jsfiddle.net/HtNK3/13/

Code

$(document).ready(function() {
    var visible = false;

    $('#clickable_div').click(function() {
      visible = true;
      $('#nav_menu').showMenu({
            parent:'#clickable_div'
      });                
    }).mouseleave(function() {

    if(visible) {
        visible = false;
        window.setTimeout(function(){$('#nav_menu').hide('blind');}, 1000);
    }
    });       //end mouseleave     

    $('#l1').click(function() {
    alert("...");               
    });  
});
2
  • Your code is working exactly as its supposed to. Its just not what you want. So, what do you want exactly? Commented Apr 6, 2012 at 7:39
  • when i click the div , menu show's up. When i move the mouse over the menu it should not close up..which is happening currently. Commented Apr 6, 2012 at 7:41

2 Answers 2

2

my problem is when i hover over the menu it should not slideUp which is currently happening How can i fix this ?

Then don't hide the box on mouseleave. Remove all this:

.mouseleave(function() {

    if(visible) {
        visible = false;
        window.setTimeout(function(){$('#nav_menu').hide('blind');}, 1000);
    }
 })

EDIT:

The simplest way I could think of is to wrap the whole thing inside another block element and bind the mouseleave event to that. I've updated your Fiddle to show the solution.

http://jsfiddle.net/HtNK3/20/

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

2 Comments

well i want it to hide out but not when the mouse is over the menu or when the mouse is over the "clickable_div".
Then, say that in your question. That's what I meant by "What do you want to do exactly?". Let me update my answer.
0

Following code is causing problem,

     .mouseleave(function() {
        if(visible) {
            visible = false;
            window.setTimeout(function(){$('#nav_menu').hide('blind');}, 1000);
        }); 

What you are trying to do is when the mouse leave the menu header your are asking to hide the menu.

Try to detect mouse out on both the menu header and menu. Check this answer on how to do that

Js Code

There are lot of plugins already available to do this take any one of them and change the css to match your site

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.