3

I have this:

$('table.data td').click(function() {
}

But the problem is this also fires when I click on links within that column. How can I prevent that?

Tried something like table.data td :not(a) but that doesn't seem to work at all..

Thanks.

--

Nevermind, just found out about e.target.nodeName! (if that is the best way to deal with this: != 'A')

1 Answers1

5

You can stop the event propagation for the children nodes this way:

$('table.data td a').click(function(evt){
  evt.stopPropagation();
  [.. Do other stuff ..]
});

jquery stopPropagation() Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

dmarucco
  • 590
  • 4
  • 11