JS Random color generator


/ Published in: JavaScript
Save to your folder(s)

http://stackoverflow.com/questions/1484506/random-color-generator-in-javascript


Copy this code and paste it in your HTML
  1. function get_random_color() {
  2. var letters = '0123456789ABCDEF'.split('');
  3. var color = '#';
  4. for (var i = 0; i < 6; i++ ) {
  5. color += letters[Math.round(Math.random() * 15)];
  6. }
  7. return color;
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.