JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
CSS
ul li {
height: 50px;
width: 50px;
background: red;
margin: 10px 0;
transition: all 2s ease;
transform: scale(0.2);
}
JavaScript
function shuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
var arr = [];
$("ul li").each(function () {
arr.push($(this));
});
shuffle(arr);
console.log(arr);