JSFiddle - React, Tailwind, and code Playground
HTML
<button id="shuffleButton">Shuffle Colors</button>
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
<div id="div4">4</div>
<div id="div5">5</div>
JavaScript
var count = 0;
var colors = ['red', 'blue', 'green', 'black', 'pink'];
setColors();
$("#shuffleButton").click(function()
{
count = (count + 1) % colors.length;
setColors();
});
function setColors()
{
for(var i = 0; i < colors.length; i++)
{
var color = colors[(count + i) % colors.length];
var id = i + 1;
$("#div"+id).css("color", color);
}
}