js check event type is outside code example
Example: detect a click outside an element javascript
$(document).click((event) => {
if (!$(event.target).closest('#element').length) {
// the click occured outside '#element'
}
});
$(document).click((event) => {
if (!$(event.target).closest('#element').length) {
// the click occured outside '#element'
}
});