1$(document).mouseup(function(e){
2 var container = $("YOUR CONTAINER SELECTOR");
3 // if the target of the click isn't the container nor a descendant of the container
4 if (!container.is(e.target) && container.has(e.target).length === 0){
5 container.hide();
6 }
7});
8