Try the following:
$('#something').animate({ backgroundColor: "#FF0000" }, 1000, null, function () { $('#something').css("backgroundColor", "#FF0000"); });
I had variable success with animations, but found that using the built-in callback plus jQuery css seems to work in most cases. Tested in IE9, FF4, Chrome using jQuery 1.5.
For a more complete solution add this plugin:
$(document).ready(function () { $.fn.animateHighlight = function (highlightColor, duration) { var highlightBg = highlightColor || "#FF0000"; var animateMs = duration || 1000; var originalBg = this.css("background-color"); if (!originalBg || originalBg == highlightBg) originalBg = "#FFFFFF";
and name it like this:
$('#something').animateHighlight();
source share