Change innerHTML color randomly - Javascript CSS Style Property

Javascript examples for CSS Style Property:color

Description

Change innerHTML color randomly

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w  w .  j a  v  a  2 s. c  o  m*/
window.setInterval(function(){
  var t = document.getElementById('test');
  var z = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
  t.style.color = z
}, 100);
    }

      </script> 
   </head> 
   <body> 
      <div id="outer"> 
         <div id="test">
            Generate colors.
         </div> 
      </div>  
   </body>
</html>

Related Tutorials