JSFiddle - React, Tailwind, and code Playground

HTML

<div id="d1" class="d" style="background-color: rgba(252, 70, 170, 1);"></div>

CSS

.d {
    min-width: 50px;
    height: 40px;
    margin:10px;
    padding:10px;
    line-height:40px;
}

JavaScript

$(function() {
    for(var i=0; i<50; i++) {
        // Locate the last red <div>
        var $last = $('.d:last');
        
        // Get its used color
        var lastColor = window.getComputedStyle($last[0], null)
            .getPropertyValue('background-color');
        
        $last.text('bg-color: ' + lastColor);
        
        // Add a new <div> with the color of the last
        $('<div class="d"></div>')
            .css({"background-color":lastColor})
            .appendTo('body');
    }
});