Create random color - Javascript CSS Style Property

Javascript examples for CSS Style Property:color

Description

Create random color

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(){/* www .j  a  v a  2s .c om*/
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