jQuery animate() not working with colors

2020-02-11 04:23发布

问题:

I'm trying to do some simple jQuery test in Confluence 4.1.9.

$("div#test").css("background","#F00");

works, but

$("div#test").animate({background:"#F00"});

doesn't. Am I missing something? Or maybe animate() just doesn't work in Confluence? Hopefully someone can help me out with this. Thank you.

[Update]

Thank you guys, it totally worked! But fyi, it did not work in preview, which made me scratch my head a bit. Good thing I decided to save the page and see what happens anyway. :P

回答1:

jQuery Core does not support color animations out of the box.

You will have to use something like jQuery UI or a standalone jQuery Color plugin for your call to animate() to work as expected.