Я бы сделал это так
<table width="301" border="0" cellspacing="5" cellpadding="0" id="selectedproducts" =="">
<tbody>
<tr>
<th width="56" scope="col">Product:</th>
<th width="48" scope="col">Size:</th>
<th width="71" scope="col">Colour:</th>
<th width="41" scope="col">Qty</th>
<th width="55" scope="col">Price</th>
<th width="55" scope="col">Delete</th>
</tr>
<tr id="product_1">
<td>Shuttle</td>
<td>54.95</td>
<td>Red</td>
<td>1</td>
<td></td>
<td><a>[X]</a></td>
</tr>
<tr id="product_2">
<td>Shuttle</td>
<td>54.95</td>
<td>Red</td>
<td>1</td>
<td></td>
<td><a>[X]</a></td>
</tr>
</tbody>
</table>
и jQuery:
$('tr a').live('click', function () {
$(this).closest('tr').remove();
});
другой альтернативой этому селектору будет
$('tr[id^="product_"] a').live('click', function () {
// you could ge the id number from the tr to do other things with
var id = $(this).closest('tr').attr('id').replace("product_","");
$(this).closest('tr').remove();
});
это ограничило бы его только тем, чей идентификатор начинается с "product _"
альтернативно вы можете удалить элемент с _id, оканчивающимся вот так
$('tr[id^="product_"] a').live('click', function () {
// you could ge the id number from the tr
var id = $(this).closest('tr').attr('id').replace("product_","");
//then you could remove anything the that ends with _id
$('[id$="_'+id+'"]').remove();
});
Я немного изменил код, вот это ДЕМО