I've got a table that I can't seem to delete the rows from no matter what I try. Its a simple table of 5 columns and a few rows generated from a php/mysql lookup using Json. I'd eventually like to delete the row from the mysql table with the button click but I'm stuck with the "easy" part of deleting the row in jquery.
Here is the code to create my table:
var table = $('<table></table>').addClass('tbc');
for (var i = 0; i < json.admin_tables.length; i++) {
var row = $('<tr></tr>').addClass('guid').attr('id', i).add('<td>' + json.admin_tables[i].Room + '</td><td>' + json.admin_tables[i].time + '</td><td>' + json.admin_tables[i].Desk + '</td><td>' + i + '</td><td><input type="button" id="'+ i + '" class="delete" value="Delete row ' + i + '"</td>');
table.append(row);
$('#roomTable').append(table);
}
The following code does nothing at all however (no errors in firebug)
$('.delete').click(function() {
$(this).closest("tr").remove();
}
Changing "tr" to "td" will delete the button only and I don't want to have to delete every field individually!