JSFiddle - React, Tailwind, and code Playground

HTML

<div id="box"></div>
<br>
<button type="button" onClick="fun()">Click here</button>

CSS

#box {
    height:200px;
    width:200px;
    background:#c0c0c0;
}

JavaScript

function fun() {
    setInterval(fun1, 3000);
}

function fun1() {
    var x = document.getElementById("box");
    x.style.backgroundColor = "red";
}