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
Post a Comment