I have a div which has some text content( eg: My Name ) and the div is in RED background colour
Or you could do the math and do the color change. http://jsfiddle.net/rustyDroid/WRExt/2/
> $("#btn").click(function(){
> $('#bar').animate({ width: '300px' },
> {
> duration:10000,
> easing:'linear',
> step:function(a,b){
> var pc = Math.ceil(b.now*255/b.end);
> var blue = pc.toString(16);
> var red = (255-pc).toString(16);
> var rgb=red+"00"+blue;
> $('#bar').css({
> backgroundColor:'#'+rgb
> });
> }
> })
> });