JSFiddle - React, Tailwind, and code Playground
by Giorgio Malvone
HTML
<div id="color">Hello World!</div>
<input type="button" value="Generate!"onclick="slide()"></input>
CSS
body{
background-color:#232c31;
}
#color{
color:#ecf0f1;
}
JavaScript
var colorDiv = document.getElementById("color");
var colors = ["pink","yellow","aqua","tomato","SpringGreen"];
function colorGen()
{
}
function slide() {
var num = 0, style = document.getElementById('color').style;
window.setInterval(function () {
// increase by num 1, reset to 0 at 4
num = (num + 1) % 4;
// -600 * 1 = -600, -600 * 2 = -1200, etc
colorDiv.style.color = colorDiv.innerHTML= colors[Math.floor(Math.random()*5)];
}, 900); // repeat forever, polling every 3 seconds
}