Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if click is inside div javascript

var container = document.getElementsByClassName('container')[0];
document.addEventListener('click', function( event ) {
  if (container !== event.target && !container.contains(event.target)) {    
    console.log('clicking outside the div');
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #click #div #javascript
ADD COMMENT
Topic
Name
8+6 =