Skip to content

Instantly share code, notes, and snippets.

@terkel
Created January 11, 2012 05:31
Show Gist options
  • Select an option

  • Save terkel/1593214 to your computer and use it in GitHub Desktop.

Select an option

Save terkel/1593214 to your computer and use it in GitHub Desktop.
jQuery Shuffle plugin
// jQuery Shuffle plugin, https://gist.github.com/1593214
// see http://www.fumiononaka.com/TechNotes/Flash/FN0212002.html
(function ($) {
$.fn.shuffle = function () {
var i = this.length,
j,
t;
while (i){
j = Math.floor(Math.random()*i);
t = this[--i];
this[i] = this[j];
this[j] = t;
}
return this;
};
$.shuffle = function ($arr) {
return $arr.shuffle();
};
})(jQuery);
// jQuery Shuffle plugin, https://gist.github.com/1593214
// see http://www.fumiononaka.com/TechNotes/Flash/FN0212002.html
(function(b){b.fn.shuffle=function(){for(var a=this.length,c,b;a;)c=Math.floor(Math.random()*a),b=this[--a],this[a]=this[c],this[c]=b;return this};b.shuffle=function(a){return a.shuffle()}})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment