<div class="box">
<div class="d1">Click outside</div>
</div>
$(function(){
$(document).click(function(e){
var target = $(e.target);
if(target.closest('.d1').length == 0){
alert("Clicking on the outside of d1");
}
});
})