Jquery: fade menu out when clicking on anything EXCEPT the menu itself, short piece of code.
Posted
by ExodusNicholas
on Stack Overflow
See other posts from Stack Overflow
or by ExodusNicholas
Published on 2010-02-09T19:02:09Z
Indexed on
2010/05/16
7:20 UTC
Read the original article
Hit count: 215
jQuery
.saf_search is a button, when it's clicked, the menu .lisearch fades in, when you click anywhere on the page EXCEPT for on the menu .lisearch, then it should fade out(that's how it's SUPPOSED to work) Does anyone know why this isn't working? It fades in, and the first time i click anywhere on the page it fades out, but the second time i try to fade in the menu, it will quickly fade out again without me clicking the document. i think this has to do with .one, but i had it working before my hard drive crashed, and now i can't figure out how to get it working again...
$('.saf_search').click(function() {
$('.lisearch').fadeIn(200);
});
$(document).click(function(){
jQuery(".lisearch").click(function(){ return false; });
jQuery(document).one("click", function() { jQuery(".lisearch").fadeOut(); });
});
© Stack Overflow or respective owner