1var container = document.getElementsByClassName('container')[0];
2document.addEventListener('click', function( event ) {
3 if (container !== event.target && !container.contains(event.target)) {
4 console.log('clicking outside the div');
5 }
6});
7