JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">test</div>
<div id="test2">test2</div>

CSS

#test {
    background-color: green;
}

JavaScript

var elem = document.getElementById('test');
    var elem2 = document.getElementById('test2');    
    
    var color = window.getComputedStyle(elem).getPropertyValue('background-color');
    elem2.style.backgroundColor = color;