How can I manually set a position with some code?
Ok
Ive got some div with the sortable() behavour :
<div class="sort" id="a"></div>
<div class="sort" id="b"></div>
<div class="sort" id="c"></div>
<div class="sort" id="d"></div>
<div class="sort" id="e"></div>
I want to set manually(click on a button) the order with sortable jquery ui behavor with some code To get something like this
<div class="sort" id="b"></div>
<div class="sort" id="c"></div>
<div class="sort" id="e"></div>
<div class="sort" id="d"></div>
<div class="sort" id="a"></div>
Any idea
There isn't a built-in option to reorder the elements, however using jQuery you can reorder the elements like this:
$("#sortable").sortable().disableSelection();
$("#sortable li:eq(3)").insertAfter($("#sortable li:eq(4)"));
$("#sortable li:eq(0)").insertAfter($("#sortable li:eq(4)"));
jsFiddle example. Original order: A, B, C, D, E. New order: B, C, E, D, A.
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