Jquery click event propagation

Posted by ozsenegal on Stack Overflow See other posts from Stack Overflow or by ozsenegal
Published on 2010-02-11T12:22:26Z Indexed on 2010/04/03 8:03 UTC
Read the original article Hit count: 276

Filed under:
|
|

I've a table with click events bind to it rows (tr).

Also,there're A elements with it owns click events assigned inside those rows.

Problem is when i click on A element,it also fires click event from TD.And Im dont want this behavior,i just want to fire A click's event.

Code:

//Event row TR

 $("tr:not(:first)").click(function(){
    $(".window,.backFundo,.close").remove();
    var position = $(this).offset().top;
    position = position < 0 ? 20 : position;
    $("body").append($("<div></div>").addClass("backFundo"));
    $("body").append($("<div></div>").addClass("window").html("<span class=close><img src=Images/close.png id=fechar /></span>").append("<span class=titulo>O que deseja fazer?</span><span class=crud><a href=# id=edit>Editar</a></span><span class=crud><a href=# id=delete codigo=" + $(this).children("td:first").html() + ">Excluir</a></span>").css({top:"20px"}).fadeIn("slow"));
    $(document).scrollTop(0);
     });

//Element event

$("a").live("click",function(){alert("clicked!");});

Whenever you click the anchor it fires event from it parent row.Any ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about click