tags:

views:

28

answers:

2

Mouseenter of DIV A sets DIV B to show(). What I want is on mouseleave of DIV A if they are not hovering over DIV B, hide DIV B. But, on mouseleave of DIV A if they are hovering over DIV B keep showing DIV B.

$('#DIVA').mouseenter(function() {
        $('#DIVB').show();  
    }).mouseleave(function() {      
        //if DIVB not hovering
            $('#DIVB').hide();
        //end if
    });
+1  A: 

Could you add a class to #DIVB on hover then check for it on mouseleave for #DIVA?

$('#DIVB').hover(function(){
    $(this).addClass('active');
}, function(){
    $(this).removeClass('active');
})

$('#DIVA').mouseenter(function() {
    $('#DIVB').show();  
}).mouseleave(function() {      
    if(!$('#DIVB').hasClass('active')){
        $('#DIVB').hide();
    }
});
Sam
I actually used bits of both of your solutions. Thank you both!
s15199d
+1  A: 

It could be as simple as just using hover.

http://jsbin.com/ojipu/2

...but that depends on what the markup looks like.

Mark