jquery - How to make a closing a sliding div when you click outside of it? -


please me! create simple sliding block , i'm trying make close when click anywhere on page, except sliding "black" content.

see jsfiddle: jsfiddle.net/2dar6/233/

javascript

$(".black ").hide(); $(".white").show(); $('.white').click(function(){     $(".black ").slidetoggle(150); }); 

html

<div class="black">     content </div>  <a href="#" class="white">click me!</a><br /> 

something perhaps http://jsfiddle.net/he2qg/

$(".black ").hide().click(function(){     return false; }); $(".white").show().click(function(){     $(".black ").slidetoggle(150);     return false; }); $(document).click(function(){     $(".black ").slideup(150); }); 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -