1var ignoreClickOnMeElement = document.getElementById('someElementID');
2
3document.addEventListener('click', function(event) {
4 var isClickInsideElement = ignoreClickOnMeElement.contains(event.target);
5 if (!isClickInsideElement) {
6 //Do something click is outside specified element
7 }
8});
1$(document).click((event) => {
2 if (!$(event.target).closest('#element').length) {
3 // the click occured outside '#element'
4 }
5});