$.fn.shuffleChildren = function() ( $.each(this.get(), function(index, el) ( var $el = $(el); var $find = $el.children(); $find.sort(function() ( return 0.5 - Math.random(); )); $el.empty(); $find.appendTo($el); )); );
Uso
$(".parent-element").shuffleChildren();
Consulte la función Pen
jQuery Shuffle de Chris Coyier (@chriscoyier)
en CodePen.