jQuery Random Colour Generator

I can’t remember the inspiration for this crazy thing, but I’m sure somewhere out there someone is looking for a random colour generator that is done in jQuery.

So if you’re feeling in the mood to have a randomly changing colour … this is the script for you! Essentially it’s just generating a random number between 0 and 255 for red, green, and blue. It then uses CSS to change the colour property of an element (that’s easily customizable by you).

So check out the demo.

6 Responses

  1. good one yaar!!!!

  2. emma:

    great !

    erational did something similar but the colors are animated:
    http://www.erational.org/randomColor.html

  3. Great!

    But do you know how we can make a random with only 20 colors?

    • Ben:

      20 colours randomly generated at once should be very straightforward. Create a function that generates a random colour and returns its value, call it 20 times in a loop.

  4. fred:

    is this not easier ?

    function randomColor(){
    return ‘#’+Math.floor(Math.random()*16777216).toString(16);
    }

Leave a Reply