Click events on overlapping items

MicTech picture MicTech · Nov 13, 2009 · Viewed 10.5k times · Source

I have

  • table row with click event
  • button with click event, that button is on table row

and I have problem. When I hit button, row click event execute too, but I don't want this behavior. I want only button click execute, without row click.

Answer

stpe picture stpe · Nov 13, 2009

Using jQuery (due to question tag):

$('#yourButton').click(function(e) {
    // stop event from bubbling up to row element
    e.stopPropagation();

    // now do your stuff
});