javascript - jquery offclick? -


i have 'li' pops down when click on 'link' via jquery's 'click'.

does know of clean way along lines of 'offclick'? in, when click off of element, hide pop down?

thanks! matt

you want assign click listener window , assign click listener link. inside link click listener, you'll want stop event propagation doesn't travel dom tree , fire window's click listener.

something should trick:

$(window).click(function(){   $('li#my_li').slideup(); });  $('a#my_link').click(function(event){     try     {         event.stoppropagation();     }     catch(err)     {         // ie way         window.event.cancelbubble=true;     }   $('li#my_li').slidedown(); }); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -