Is there any way to swap a list item with another using jQuery?
assume this list:
<ul>
<li id="1"></li>
<li id="2"></li>
<li id="3"></li>
<li id="4"></li>
<li id="5"></li>
</ul>
How can change the place item 2 with item 4?
so that it
<ul>
<li id="1"></li>
<li id="4"></li>
<li id="3"></li>
<li id="2"></li>
<li id="5"></li>
</ul>
is there any way without using absolute positioning ?
$('#2').insertAfter($('#3'));
$('#4').insertAfter($('#1'));
jsFiddle example
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