Reputation: 35754
I am trying to change the index of a list item in jquery by doing the following:
$(this).index(2);
This does not appear to work correctly.
Is the only way to achieve this by using insertBefore/insertAfter?
Upvotes: 0
Views: 2174
Reputation: 318302
index()
simply returns the index, it does not set it, so you have to use a method that actually changes the DOM to move the element around.
$(this).siblings().eq(1).after(this);
Upvotes: 3