1<script>
2$(document).mouseup(function(e){
3 var container = $("#elementID");
4
5 // If the target of the click isn't the container
6 if(!container.is(e.target) && container.has(e.target).length === 0){
7 container.hide();
8 }
9});
10</script>