JQUERY, if you do not soar

Mouseenter DIV A sets DIV B to display (). What I want is on mouseleave DIV A, if they are not hovering over DIV B, hide DIV B. But on the mouse player DIV A, if they hover over DIV B, continue to show DIV B.

$('#DIVA').mouseenter(function() { $('#DIVB').show(); }).mouseleave(function() { //if DIVB not hovering $('#DIVB').hide(); //end if }); 
+6
jquery
source share
2 answers

It can be as simple as using a hover .

http://jsbin.com/ojipu/2

... but it depends on how the markup looks.

+4
source share

Could you add the class to #DIVB on hover and then test 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(); } }); 
+5
source share

All Articles