ufaclub,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
div.hot{
width: 100px;
height: 100px;
border: 1px dashed Gray;
padding: 5px;
transition: .4s;
}
.Red{
background-color: Red;
}
.Green{
background-color: Green;
}
.Yellow{
background-color: Yellow;
}
</style>
</head>
<body>
<div class="hot Red" id="krn"></div>
<script>
(function fn(b, a) {
document.querySelector("#krn").classList.remove(b[a]);
a = ++a % b.length;
document.querySelector("#krn").classList.add(b[a]);
window.setTimeout(fn, 2000, b, a);
})(["Red", "Green", "Yellow"], 0);
</script>
</body>
</html>