jQuery - How to fade in/out from one color to another? (possible 3rd party plugin fo jQuery?)

user798596 picture user798596 · Nov 30, 2011 · Viewed 20k times · Source

I'm looking for a jQuery script or a 3rd party plugin for jQuery, which can create a fade in/out effect based on "from color" and "to color". Example how I see it:

$( selector ).fadeColor({
    from: "#900", // maroon-red color
    to: "#f00",   // blood-red color
}, 3000); // last argument is the time interval, in milliseconds in this particular case it's based for 3 seconds

Answer

James Allardice picture James Allardice · Nov 30, 2011

jQuery UI extends jQuery's animate method to include colour animation. You can then do something like:

$("#someId").animate({backgroundColor: "#ff0000" });

Here's a working example.