Source from James Padolsey.  In this post, I just Created a Demo using his code.
You can find pure javascript way also from his article
$.fn.shuffle = function () {
        var allElems = this.get(),
            getRandom = function (max) {
                return Math.floor(Math.random() * max);
            },
            shuffled = $.map(allElems, function () {
                var random = getRandom(allElems.length),
                    randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
            });
        this.each(function (i) {
            $(this).replaceWith($(shuffled[i]));
        });
        return $(shuffled);
    };$('selector').shuffle();You can find pure javascript way also from his article
 
 Posts
Posts
 
 
This comment has been removed by the author.
ReplyDelete