click - how to close the event of a target in jquery? -
i have several menu buttons in menu panel. each button opens css:box(100px 100px) now, when click on 1 box opens ,when click on other 1 want 1 open the former 1 close simultaneoulsy.
$(document).ready(function(){ //this click anywhere function $(document).click(function(e) { var target = e.target; if (!$(target).is('li.faq')) { $('#faq_container').hide(); } }); });
is there general way can achieve ? instead of checking if element in class open , selectively closing?
i have used $('html').click() function closes box before open it!
create function resets menu state , call @ beginning of click handler.
something like
function clear(){ $('#faq_container').hide(); //hide else here }
then clear() before open new css box.
Comments
Post a Comment