3

我想将输入框的背景从白色更改为另一种颜色,然后以缓慢褪色的方式再次变回白色。我已经尝试过动画它根本不起作用。没有错误。

<script type="text/javascript" src="/jsp/ui/jquery-ui/js/jquery-1.8.3.min.js"></script>
...
$(document.getElementById(id)).animate({ backgroundColor: "#4E1402" }, 500);

更新

这工作正常

$(document.getElementById(id)).animate({ width: "400px" }, 500);
4

3 回答 3

6

jQuery 不能为颜色设置动画。改用这个插件。

http://www.bitstorm.org/jquery/color-animation/

(只是增加了 4kb )

或 jquery UI 动画:

http://jqueryui.com/animate/ (如下@Adam 所述)

于 2013-05-29T13:09:14.797 回答
0

你需要这个插件来用 jQuery 动画颜色:http: //archive.plugins.jquery.com/project/color

于 2013-05-29T13:10:48.153 回答
0

你是否也包含了 jquery-ui 库?

如果我没记错的话,您要引用的当前元素必须在开始时设置一些背景颜色。

于 2013-05-29T13:11:18.043 回答