Niños aleatorios | Programar Plus

$.fn.shuffleChildren = function() {
    $.each(this.get(), function(index, el) {
        var $el = $(el);
        var $find = $el.children();

        $find.sort(function() {
            return 0.5 - Math.random();
        });

        $el.empty();
        $find.appendTo($el);
    });
};

Uso

$(".parent-element").shuffleChildren();

Ver la pluma
Función jQuery Shuffle de Chris Coyier (@chriscoyier)
en CodePen.

(Visited 4 times, 1 visits today)