Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save monyskynet/6709393 to your computer and use it in GitHub Desktop.
Save monyskynet/6709393 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.randomize = function(childElem) {
return this.each(function() {
var $this = $(this);
var elems = $this.children(childElem);
elems.sort(function() { return (Math.round(Math.random())-0.5); });
$this.remove(childElem);
for(var i=0; i < elems.length; i++)
$this.append(elems[i]);
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment