DEV Community

Discussion on: Random colour with JavaScript

Collapse
 
alexnfsc175 profile image
alexnfsc175 • Edited

lets test this trick, in this page open chrome console and paste this code, and see the title change color:

for (var i=0;i<=10000;i++) {
   (function(ind) {
       setTimeout(function(){document.querySelector('#main-title > h1').style.color = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6,'0')}`;}, 1000 + (300 * ind));
   })(i);
}
Collapse
 
telmo profile image
Telmo Goncalves

Awesome 😆