title: Detect click outside div using javascript
body: <p>I'd like to detect a click inside or outside a div area. The tricky part is that the div will contain other elements and if one of the elements inside the div is clicked, it should be considered a click inside, the same way if an element from outside the div is clicked, it should be considered an outside click.</p>
  
  <p>I've been researching a lot but all I could find were examples in jquery and I need pure javascript.</p>
  
  <p>Any suggestion will be appreciated.</p>