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 - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -