//<![CDATA[ var shuffle = function(v){ for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); return v; }; var a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; document.write("A = ", a.join(","), "<br><br>shuffle(A) = ", shuffle(a)); if (!Array.prototype.shuffle) { Array.prototype.shuffle = function() { for(var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x); return this; }; } document.write("<br>A.shuffle() = ", a.shuffle()); //]]> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 请刷新页面查看随机排序效果。