JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="yellow"></div>
<div class="red"></div>
<div class="green"></div>
<br>
<div class="pink"></div>
<div class="orange"></div>
<div class="black"></div>
<div class="white"></div>
</div>
CSS
.container div {
width: 160px;
height: 20px;
}
JavaScript
var $container = $("div.container");
setInterval(function(){
$container.html(shuffle($container.children().get()));
}, 500);
$("div.container div").each(function(){
var color = $(this).attr("class");
$(this).css({backgroundColor: color});
});
function shuffle(o){
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};