HTML + jQuery dropdown: When any other part of the page is clicked, FadeOut? -


this simple question, i'm designing html dropdown.

$('#bible-trans').click(function() {     $('#bible-translation-list').fadetoggle('fast'); }); 

where #bible-trans main dropdown button, content of dropdown #bible-translation-list. when hit main dropdown, content toggles. simple.

what i'd if user hits anywhere else on page dropdown fades out.

$("*").not('#bible-trans').click(function() {     $('#bible-translation-list').fadeout(); }); 

this have right now, i'm pretty sure it's incorrect—well because doesn't work— when click toggle #bible-trans, toggles , fades away immediately. using not() selector correctly?

edit: think has lot fact #bible-trans child of * (obviously). way can work through that?

heres 1 way possible of doing it

http://jsfiddle.net/76guj/29/

$(function(){     $(document).click(function() {        if($("#anotherdiv").is(":visible")){            $("#anotherdiv").fadeout();        }      });     $("#testdiv").click(function(){        $("#anotherdiv").fadein('fast');        event.stoppropagation();     }); }); 

another example mu short

http://jsfiddle.net/ambiguous/76guj/32/


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -