$(this).parent(".unit").siblings().children("ul").hide(); }); $(".unit li").on("click",function(e){ e.stopPropagation(); $(this).addClass("active").siblings("li").removeClass("active"); $(this).parents("ul").hide(); //resultTable.ajax.reload(); }); $("body").on("click",function(){ $(".unit ul").each(function(i,n){ $(n).hide(); }); });