我正在构建一个自定义的jQuery插件,其中包括实时删除表格中的记录等许多功能。当记录被删除时,我希望其行的背景颜色变为红色并向上滑动消失。
以下是我的代码片段,它没有执行任何颜色变化动画,也没有将行向上滑动。然而,当应该执行向上滑动动画时,它确实删除了该行。在查看下面的代码时需要知道一些事情:
- "object"变量是对单击并触发删除操作的对象的jQuery引用。
- "object.parent().parent()"对象是将要删除的行。
- "deleteHighlight" CSS类包含将行变为红色的颜色。
- "addClass"方法使用jQueryUI的"addClass"方法,而不是jQuery的方法。它允许有一个动画效果和回调函数。
object.parent().parent().addClass('deleteHighlight', 1000, function() {
//Fold the table row
$(this).slideUp(1000, function() {
//Delete the old row
$(this).remove();
});
});
这是正在执行的HTML,没有什么特别的:
<table class="dataTable">
<thead>
<tr>
<th> </th>
<th>Title</th>
<th>Content Snapshot</th>
<th>Management</th>
</tr>
</thead>
<tbody>
<tr class="odd" id="11" name="1">
<td class="center width50"><a class="dragger"></a><a class="visibilityTrigger eyeShow"></a></td>
<td class="center width150">Title</td>
<td>
<div class="clipContainer">Content</div>
<div class="hide contentContainer">Content</div>
<div class="hide URLContainer">my-url</div>
</td>
<td class="center width75"><a class="edit"></a><a class="delete"></a></td>
</tr>
</tbody>
</table>
能否提供一个示例来帮我解决这个问题?
感谢您的时间。