1
我有一个3列6行的表。我想将其中一些内容复制到新创建的列中,但将它们插入到中间。因此,它看起来像这样:复制多个TDS
有了这个aprroach:
$("table td:nth-child(2) [id$=2]").each(function(i) {
var $newCell = $(this).wrap('<td></td').parent();
var $newRow = $("table td:nth-child(2) [id$=1]").eq(i).parents('tr');
$(this).parents('tr').remove();
$newRow.append($newCell);
});
$("table td:nth-child(2) [id$=3]").each(function(i) {
var $newCell = $(this).wrap('<td></td').parent();
var $newRow = $("table td:nth-child(2) [id$=1]").eq(i).parents('tr');
$(this).parents('tr').remove();
$newRow.append($newCell);
});
我得到的结果是:
所以新列应之间插入非常左列,并与Abc
列,而不是在正确的。