JSFiddle - React, Tailwind, and code Playground

by Tan

HTML

<div class="box1" id="box"></div>

<p onclick="change1()">START</p>

CSS

.box1 {width:100px;height:100px;background-color:red;}

.box2 {width:100px;height:100px;background-color:blue;}

JavaScript

function change1(){
document.getElementById("box").className = "box2";
setTimeout(function(){change2();},1000);
}

function change2(){
document.getElementById("box").className = "box1";
setTimeout(function(){change1();},1000);
}