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

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

java - Why is BlockingQueue.take() not releasing the thread? -

jQuery Ajax Render Fragments OR Whole Page -