Nave Tseva
Nave Tseva

Reputation: 878

JQuery - background color fade out animation doesn't work

I have th following script

 $("button#submit").click(function () {
 $("tr[data-id='" + lastRefId + "']").css("background-color", "#8aabf0");
 $("tr[data-id='" + lastRefId + "']").animate({ backgroundColor: "white"}, 'slow');
});

It's a simple script that should change the backgrund to the color above and than change it back to the previous color (white). The first line works, but the second doesn't.

Why and how should I fix it?

Upvotes: 2

Views: 1022

Answers (1)

Kiyarash
Kiyarash

Reputation: 2578

jQuery don't support background color in animation method... by itself
You have to download the jquery-Color.js from the jQuery site and append it after the jQuery source code, then you can use the animation() with background color
The first line works, because you used CSS method and background-color as a CSS property haven't any problem, In second line you used animation...
and you have to write the css properties as an animation argument in camel-case;
for example background-color, must to be backgroundColor

Upvotes: 2

Related Questions