JSFiddle - React, Tailwind, and code Playground

by Amir Sharifian

HTML

<!-- softafzar.net -->

<div class="all">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
</div>

CSS

.all > div {
    background: yellow;
    margin: 5px;
    padding: 5px;
    display: inline-block;
}

JavaScript

(function (d) {
    d.fn.shuffle = function (c) {
        c = [];
        return this.each(function () {
            c.push(d(this).clone(true))
        }).each(function (a, b) {
            d(b).replaceWith(c[a = Math.floor(Math.random() * c.length)]);
            c.splice(a, 1)
        })
    };
    d.shuffle = function (a) {
        return d(a).shuffle()
    }
})(jQuery);

$(function () {
    $('.all > div').shuffle();
});