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); });
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(); } });
Comments
Post a Comment