views:

1036

answers:

1

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?

+1  A: 
rahul
no that's not quite.I've already tried this.Nothing happens.
Can you post your HTML markup?
rahul
I've a normal table.Then I create new anchor elements promagamatically,and append to that rows.
Try giving return false at the end of the anchor event handler.
rahul
Add a `e.preventDefault();` in there as well for good measure, there's some browser inconsistency between propagation prevention.
Nick Craver
nope,neither return false or preventDefault works;