JSFiddle - React, Tailwind, and code Playground

by Dawid Karwat

HTML

<div id="myID"></div>

CSS

#myID{
	width:	100px;
    height: 100px;
	background-color: blue;
}

JavaScript

var i = 0;
function changecolor()
{		
	var thesquare = document.getElementById('myID');
	switch (i)
	{
		case 0 :
		thesquare.setAttribute("background-color","red");
		++i;
		break;
		
        case 1 :
		thesquare.setAttribute("background-color","green");
		++i;
		break;
		
        default :
		thesquare.setAttribute("background-color","blue");
		i=0;
		break;
	}
}
setInterval("changecolor()",1000);