Just check to see if the clicked element was in the accordian or not
$(document).click(function(e) {
if (!$( "#acc" ).is(e.target) && !$( "#acc" ).has(e.target).length) {
$('#acc').accordion('activate', -1);
}
});
Question
Please help me! I create a simple accordion and I'm trying to make it close when you click anywhere on the page, except for accordions content.
See JSFiddle: jsfiddle.net/2DaR6/201/
Solution
Just check to see if the clicked element was in the accordian or not
$(document).click(function(e) {
if (!$( "#acc" ).is(e.target) && !$( "#acc" ).has(e.target).length) {
$('#acc').accordion('activate', -1);
}
});