tags:

views:

24

answers:

1

I have a table with four columns. I'm adding rows to the table dynamically with jquery and in the fourth column is a "Delete" link. I need to remove the link from the row when a new row is added. This is all happening and working as I want it too. The problem comes when I want to delete the row. I need to put the delete link back on the previous row in the existing td, the issue I have is that a new td is being created and the link being placed into it. This is the code

function RemoveUnsavedTier() {
    $('#TierDetails tr:last').remove();
    $('#TierDetails tr:last td:last').after("<a href='#' id='RemoveTier'>Delete tier</a>");
}

I know it's because I'm using after but I don't know what I should be using instead.

+2  A: 

user append instead of after

$('#TierDetails tr:last td:last').append("<a href='#' id='RemoveTier'>Delete tier</a>"); 
Chinmayee