Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

detect a click outside an element javascript

$(document).click((event) => {
  if (!$(event.target).closest('#element').length) {
    // the click occured outside '#element'
  }        
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #detect #click #element #javascript
ADD COMMENT
Topic
Name
6+2 =