JSFiddle - React, Tailwind, and code Playground
HTML
<input id="select1" name="test" type="radio" checked />
<label for="select1">Red</label>
<input id="select2" name="test" type="radio" />
<label for="select2">Green</label>
<input id="select3" name="test" type="radio" />
<label for="select3">Blue</label>
<input id="select4" name="test" type="radio" />
<label for="select4">Orange</label>
<div class="colorDiv"></div>
CSS
.colorDiv{
width:50px;
height:50px;
background-color:red;
}
JavaScript
function ChangeColor(color) {
var clrDiv = document.getElementsByClassName("colorDiv")[0];
clrDiv.style.backgroundColor = color;
}
document.getElementById("select1").onclick = function() { ChangeColor(""); }
document.getElementById("select2").onclick = function() { ChangeColor("green"); }
document.getElementById("select3").onclick = function() { ChangeColor("blue"); }
document.getElementById("select4").onclick = function() { ChangeColor("orange"); }