How to exclude links from the .click handle


I'm trying to handle .click action but exclude links from it so that you could click on a link in an element without firing .click.

I've got no clue how to do that. I've tried z-indexes, position: absolute, relative but nothing worked.

div {
background: yellow;
height: 200px;
   $(function() {
      $( "div" ).click(function() {
          alert( "Click handler." );
        <a target="_blank" href="">Link</a>

Any help? Thanks!

You can check the 'currentTarget' vs 'target', the currentTarget is the exactly the object that you putted the bind, and the 'target' is the element that is clicked, that could be any element inside your div. This way you will ensure that the event will only be fired when the click is in the div.

$(function() {
    $('div').bind('click', function(ev) {
        if($(ev.currentTarget).get(0) == $( {