1$(document).click(function(){
2 $("#try").hide();
3});
4
5$("#try").click(function(e){
6 e.stopPropagation();
7});
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>
1<body>
2 <p id="try">Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.
3
4</p>
5</body>