Random hex color Generator JavaScript

by in on

Short and effective script to generate random hex color. We start with random number to multiply with white color (Hex Code is 0xFFFFFF ), now we have to convert the random generated values into the hexadecimal value to display the color. To convert integer values into hexadecimal i have used .toString( radix ) where:

  • 2 – The number will show as a binary value
  • 8 – The number will show as an octal value
  • 16 – The number will show as an hexadecimal value

 

HTML Section

 

 

Find the fiddle on http://jsfiddle.net/jogesh_pi/2QNRq/