Reputation: 1077
I have a table. I want to take all ninth TDs in each TR, and place it after the first original TD in that same TR.
This code takes the ninth TD, and places it right after the parent TR. I want to place it after the first original TD in that same TR:
$('td:nth-child(9)').each( function(){
$(this).prependTo($(this).parent());
});
What I need is an equivalent of:
.parent():first-child
Upvotes: 0
Views: 701
Reputation: 318302
$('td:nth-child(9)').each( function(){
$(this).siblings('td:first').after(this);
});
Upvotes: 2
Reputation: 2150
try this
$('td:nth-child(9)').each( function(){
$(this).siblings('td').eq(0).after(this);
});
Upvotes: 2