Jquery: fade menu out when clicking on anything EXCEPT the menu itself, short piece of code.
- by ExodusNicholas
.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(); });
});