jquery - How can i hide shown div if user did not hover mouse on shown div -


i have 2 divs close each other. when hover on div one, div 2 showing.

if don't mouse hover on div 2 should fadeout. or if move mouse div 1 elsewhere div 2 should fadeout.

$(".one").mouseover(function () {     $(".two").show(); }); $(".two").mouseleave(function () {   $(".two").fadeout(1); }); 

js fiddle

you can add mouseover event on body , act according current target. close/hide element, if mouse hovers anywhere in body excpet .one , .two

$("body").mouseover(function (e) {     if(!($(e.target).is('.one') || $(e.target).is('.two'))){         $(".two").fadeout();     } }); 

updated fiddle


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -