Click inside div, but not on link

Click inside div, but not on link

Hey all!
 
I have tried searching everywhere for this.
How can I make a function that tests if the user clicks within a div, but not on a button or link inside the same div?
A click on a link or button should ignore the div click event.
 
Thanks in advance!