我有一张桌子。我想在每个TR中取所有第九个TD,并将它放在同一个TR中的第一个原始TD之后。
此代码采用第九个TD,并将其放在父TR之后。我想把它放在同一个TR中的第一个原始TD之后:
$('td:nth-child(9)').each( function(){
$(this).prependTo($(this).parent());
});
我需要的是相当于:
.parent():first-child
答案 0 :(得分:2)
$('td:nth-child(9)').each( function(){
$(this).siblings('td:first').after(this);
});
答案 1 :(得分:2)
试试这个
$('td:nth-child(9)').each( function(){
$(this).siblings('td').eq(0).after(this);
});