var count = 0, colors = ['#2F4F4F', '#6A5ACD', '#8968CD']; var elem = document.getElementById('cont'); var int = setInterval(function() { elem.innerHTML = colors[count]; if(count == colors.length - 1) clearInterval(int); }, 1000);