Reputation: 65
<ul>
<li>first children</li>
<li>second children</li>
<li>third children</li>
</ul>
How can I use Jquery to remove first children and append it to end of ul list?
Upvotes: 3
Views: 7448
Reputation: 144659
There are many methods than you can use, like appendTo
method.
$('ul li:first').appendTo('ul');
or insertAfter
method:
var $li = $('ul li');
$li.eq(0).insertAfter($li.last())
Note that element is moved and not removed.
Upvotes: 6
Reputation: 66663
You can use:
var lis = $('ul li');
lis.first().insertAfter(lis.last());
Upvotes: 1