// script adapted from http://jsbin.com/oyaxa/edit originally credited to WEBSITEDESIGNERNC.COM and said to be based on: http://plugins.jquery.com/project/jQuiz $('button').click(function() { $("div.band").randomize("table tr td", "div.member"); }); (function($) { $.fn.randomize = function(tree, childElem) { return this.each(function() { var $this = $(this); if (tree) $this = $(this).find(tree); var unsortedElems = $this.children(childElem); var elems = unsortedElems.clone(); elems.sort(function() { return (Math.round(Math.random())-0.5); }); for(var i=0; i < elems.length; i++) unsortedElems.eq(i).replaceWith(elems[i]); }); }; })(jQuery);