从一个表中删除行并使用jQuery将其添加到另一个表中 [英] Remove row from one table and add it to another with jQuery
本文介绍了从一个表中删除行并使用jQuery将其添加到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从一个表中删除一行并使用jQuery将其添加到另一个表中。我已经检查了这个类似的Stack Overflow帖子并且觉得我做的事情大致相同,但我显然错过了一些东西,因为我正在做的事情不起作用。我知道我有正确的行,因为删除工作但行没有被添加到新表中。
I am trying to remove a row from one table and add it to another with jQuery. I've examined this similar Stack Overflow post and feel like I am doing roughly the same thing but am obviously missing something as what I am doing is not working. I know I've got the right row as the remove is working but the row is not being added to the new table.
jQuery
var row = $($.fn.colorbox.element()).parents('tr');
row.fadeOut(1000, function() {
$('#NewTableBody').append(row.remove());
});
表正文
<tbody id="NewTableBody">
推荐答案
如果你只想删除并附加一个单行你可以尝试最近的()遍历函数:
If you're only looking to remove and append a single row you can try the closest() traversal function:
var $row = $($.fn.colorbox.element()).closest('tr');
$row.fadeOut(1000, function() {
$('#NewTableBody').append($row);
$row.fadeIn(1000);
});
您的行也被隐藏(因为淡出)。您需要再次显示它。
这篇关于从一个表中删除行并使用jQuery将其添加到另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文