Is it possible to animate the background-color
in jQuery, because it is not working.
$('#something').animate({
background :"red"
}, 1000);
Is it possible to animate the background-color
in jQuery, because it is not working.
$('#something').animate({
background :"red"
}, 1000);
Try this:
I've had varying success with animate, but found that using its built in callback plus jQuery's css seems to work for most cases. Tested in IE9, FF4, Chrome, using jQuery 1.5.
For a more complete solution, add this plugin:
and call it like so:
You can use CSS3 transitions for that same effect. your animate could be achived with
The only problem with this solution is IE<10 support
This is simple code to animate RGB colors using pure jQuery (and not using jQuery.Color plugin)
You'll need a plugin to do color animations with jQuery:
http://plugins.jquery.com/project/color
Using similar syntax (
...{background-color :"red"}...
), I get the errorI was able to get it working by encapsulating the CSS property
background-color
in single quotes:From the docs,
So if you use jQuery UI, you can animate background colors. Just make sure that you use
backgroundColor
and notbackground
.The color animations plugin for jQuery also does it.
Live Example: http://jsfiddle.net/thai/NXejr/2/