我不知道这甚至有可能,但我们会看到......删除元素,如果最后
我有一个表:
<table cellspacing="0" class="stripey">
<thead>
<tr>
<td class="center"></td>
<td>Plan Name</td>
<td class="options">Options</td>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $row) {
?>
<tr class="<?php echo alternator('', 'odd'); ?>" id="record-<?php echo $row['id'];?>">
<td class="center"></td>
<td><?php echo $row['name']; ?></td>
<td class="options"><img src="<?php echo base_url();?>inc/images/search.png"> <img src="<?php echo base_url();?>inc/images/pencil.png"> <a href="#" class="delete" title="delete"><img src="<?php echo base_url();?>inc/images/delete.png"></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
,你可以看到,<tr>
重复然而,对于许多在$result
...但我有一个形象让我删除的项目,所以,我写道:
$('a.delete').click(function() {
var parent = $(this).parents("tr:first");
$.ajax({
type: 'get',
url: '/plans/delete',
data: 'id='+ parent.attr('id').replace('record-', ''),
beforeSend: function() {
parent.animate({'backgroundColor':'#fb6c6c'},300);
},
success: function(msg) {
parent.children('td').wrapInner('<div>');
parent.children('td').children('div').slideUp(500,function() {
parent.remove();
$('.stripey tr').removeClass('odd');
$('.stripey tr:even').addClass('odd');
});
}
});
return false;
});
现在我想知道是什么,是如果有可能以某种方式告诉如何很多tr
项目有tbody
,所以如果有0,我可以用文本替换整个表格,说明没有。
你不应该使用'GET '删除东西;使用'POST'或'DELETE'。 – icktoofay