Autobots

Is it Possible to Use jQuery to Shift li Elements Up or Down?

Asked by Autobots 2 years ago jquery elements list


Neil Monroe
1
 
Here are some examples of what you could do:

Var list = $('#mylist'), items = list.find('li');
items.filter(':eq(3)').insertBefore(items.filter(':eq(2)')); // swap the 2nd and 3rd elements
items.filter(':first').insertAfter(items.filter(':last')); // move first item to the end
items.filter(':gt(3)').prependTo(list); // move all items with index greater than 3 to the top of the list

There are endless ways to manipulate the DOM elements. Check out the jQuery API available at the URL below to see all the methods available to do insertions.

api.jquery.com

by Neil Monroe 2 years ago

Answer this question

Is it Possible to Use jQuery to Shift li Elements Up or Down?

0 errors found:

 
0