blob: 9bdc80749c39c19416ff1d39abfd168acc60f857 [file] [log] [blame]
$.fn.shuffle = function() {
return this.each(function() {
var items = $(this).children().clone(true);
return (items.length) ? $(this).html($.shuffle(items)) : this;
});
}
$.shuffle = function(arr) {
for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
}