JSFiddle - React, Tailwind, and code Playground
HTML
<div id="mybox"></div>
<div id="buttons">
<input type="button" value="set" onclick="setColor('red')" />
<input type="button" value="get" onclick="getColor()" />
</div>
CSS
#mybox {
width: 100px;
height: 100px;
margin: auto;
background-color: #eb5;
}
#buttons {
text-align: center;
}
JavaScript
function getColor(color){
var box = document.getElementById("mybox");
alert(box.style.backgroundColor);
}
function setColor(color){
var box = document.getElementById("mybox");
box.style.backgroundColor = color;
}