window.addEventListener('click', function(e){
if (document.getElementById('clickbox').contains(e.target)){
// Clicked in box
} else{
// Clicked outside the box
}
});
$(document).click(function(){
$("#try").hide();
});
$("#try").click(function(e){
e.stopPropagation();
});
$(document).click(function (event) {
var $target = $(event.target);
if (!$target.closest('.modal-dialog').length && $('.modal-dialog').is(":visible")) {
console.log("clicked outside the element")
}
});
$(document).click(function (event) {
var target = $(event.target);
if (!target.closest('.modal-dialog').length && $('.modal-dialog').is(':visible')) {
console.log('clicked outside the element')
}
});
$(document).click(function() {
alert('clicked outside');
});
$(".menuWraper").click(function(event) {
alert('clicked inside');
event.stopPropagation();
});
<body>
<p id="try">Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.
</p>
</body>