ランダムに要素を並び替える バナーの順番をランダムで切り替えたり、おすすめ情報の並び順を切り替えたりする時に使える「jQuery Shuffle Plugin」をご紹介。 jQueryのプラグインを使用すれば、特定の要素だけランダムで表示できるようになります。 ソースコードは以下 (function($){ $.fn.shuffle = function() { return this.each(function(){ var items = $(this).children(); return (items.length) ? $(this).html($.shuffle(items)) : this; }); } $.shuffle = function(arr) { for( var j, x, i = arr.length; i; j = parseInt(Math.random(
![jQueryで要素をシャッフルするプラグイン「jQuery Shuffle Plugin」 | Web活メモ帳](https://cdn-ak-scissors.b.st-hatena.com/image/square/51c03e708c6712d49a8ff5fe82b0c5c5ced7428c/height=288;version=1;width=512/https%3A%2F%2Fblog.verygoodtown.com%2Fwordpress%2Fwp-content%2Fuploads%2F2012%2F03%2FjQuery_-Shuffle-Plugin-Yelotofu.jpg)