JSFiddle - React, Tailwind, and code Playground
by iambriansreed
HTML
<div id="box"></div>
<button type="button" onclick="button_click('red');">Red</button>
<button type="button" onclick="button_click('blue');">Blue</button>
<button type="button" onclick="button_click('green');">Green</button>
<button type="button" onclick="button_click('yellow');">Yellow</button>
<button type="button" onclick="button_click('purple');">Purple</button>
CSS
div#box
{
width:100px;
height:100px;
background-color:#000;
}
JavaScript
function button_click(color){
document.getElementById("box").style.backgroundColor=color;
}