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.

7 comments

    • Ben said:

      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.

  1. fred said:

    is this not easier ?

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

Leave a Reply

Your email address will not be published. Required fields are marked *