Is there a simple way to move an element inside its own parent?
Like this…
from:
<div class="test">hello 1</div>
<div class="test">hello 2</div>
<div class="test">hello 3</div>
to:
<div class="test">hello 1</div>
<div class="test">hello 3</div>
<div class="test">hello 2</div>
Either move a div UP or DOWN one step, or using the index to appendTo in a specific position.
You should be able to use
.prev()and.next()like this (here as a jQuery function):JSFiddle Demo