How to move list items in jQuery UI Sort without mouse, only in jQuery?

I just want to set up a link that allows the user to list this sorted list item at the top of the list. I need something like

$('.sortable li:last-child').move('.sortable li:first-child'); 

... where I can simply call the link to place any element of the list at the top of the list.

Nothing! I have found the answer. $ (id) .prependTo ($ ('# list'));

+7
jquery jquery-ui jquery-ui-sortable
source share
1 answer

Not sure if this is the best solution, but it should work.

 $('.sortable li:last-child').live('click', function() { $(this).prependTo('.sortable'); }); 

It's hard to help without seeing more code.

+2
source share

All Articles