JSFiddle - React, Tailwind, and code Playground

by mrjordy

HTML

<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>

CSS

.circle{
    width:100px;
    height:100px;
    border:1px solid;
    display:inline-block;
    }

JavaScript

var colors = ['red', 'blue', 'green', 'gray', 'black', 'yellow'];

     $('.circle').each(function(){
        var randomColor = Math.floor(Math.random() * colors.length)
        $(this).css('background-color', colors[randomColor])
                                  });