Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery move list item to end of unordered list

Tags:

html

jquery

I am using an unordered list and I want to move the list item with the class of .price to the bottom of the list.

<ul class="itemExtraFieldslist">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
    <li class="price">Item 5</li>
    <li>Item 6</li>
    <li>Item 7</li>
    <li>Item 8</li>
</ul>

I have tried using:

$('ul.itemExtraFieldslist').sortable({
    stop: function (event, ui) {
        $(this).find('li.price').appendTo(this);
    }
});

But this doesn't work. It seems like quite a simple thing but I can seem to get my head around it. I have created a jsFiddle here.

There is already an answer on Stack Overflow but it does not work (my version is based on that answer).

Thanks for your help

like image 814
David Brooks Avatar asked Oct 29 '25 01:10

David Brooks


1 Answers

I don't have an Idea what are you trying to achieve with sortable .
But here is updated Fiddle

$('ul.itemExtraFieldslist').find('li.price').appendTo('ul.itemExtraFieldslist');

Simple. !.

like image 200
Nagesh Salunke Avatar answered Oct 30 '25 18:10

Nagesh Salunke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!