I have an unsorted list (UL
) that contains sortable list items (LI
), except for the last list item. I need the last item to stay at the end of the list:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 2</li>
<li>Last item</li><!-- Should always be the last item -->
</ul>
I'm using jQuery Sortable for sorting the list items.
Does anyone know a good way to prevent list items from being dragged past the last list item?
You can pass a selector that excludes the last item in the items option:
$("ul").sortable({
items: "li:not(:last-child)"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With