JSFiddle - React, Tailwind, and code Playground
HTML
<ul class="my_lis">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
JavaScript
$.fn.reorder = function(callback) {
// random array sort @see http://javascript.about.com/library/blsort2.htm
function randOrd() { return(Math.round(Math.random())-0.5); }
return($(this).each(function() {
var $this = $(this);
var $children = $this.children();
var childCount = $children.length;
if (childCount > 1) {
$children.hide();
var indices = new Array();
for (i=0;i<childCount;i++) { indices[indices.length] = i; }
indices = indices.sort(randOrd);
$.each(indices,function(j,k) {
var $child = $children.eq(k);
var $clone = $child.clone(true);
$clone.show().appendTo($this);
if (callback != undefined) {
callback($child, $clone);
}
$child.remove();
});
}
}));
}
$(".my_lis").reorder();