views:

100

answers:

3

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.

+2  A: 

look at your code this is what you should do in the button click event stopPropagation

andres descalzo
+1  A: 

Using jQuery (due to question tag):

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

    // now do your stuff
});
stefpet
+1  A: 

You can call an extra function onClick

this is the function:

function cancelBubble(e){

e.cancelBubble = true;
if(e.stopPropagation)
 e.stopPropagation();

}

And button's onClick you can write like

onclick="yourfunctionname();cancelBubble(event)"

yourfunctionname:: is the name of your function you are already calling.