Random color for animate in jquery

javascript, jquery

Solution

You can generate a random color like this:

var newColor = '#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6);
jQuery(".font-style").animate({color: newColor}, 2000); // animate

This will create a random hex color such as #ff00cc.

Note: regular jQuery doesn't animate colors, you'll have to use jQuery color plugin or jQuery UI

Problem

I trying to add the text effect using jquery with ui `animate`. Is there is a way to show all possible color randomly without defined all colors. For example color combination is based on `RGB`. Using the animate with color like ``` setInterval(function() { jQuery(".font-style").animate({color: "red"}, 2000). animate({color: "green"}, 2000).animate({color: "blue"}, 2000);}, 400); ``` Is there is any possibilities to show the color combination of `RGB` Randomly in jquery. Any suggestion would be great. Thanks.

Original source