[英]Jquery background colour change animate not working
I want to change the background of an inputbox from white to another colour and then back to white again in a slow fading way. 我想将输入框的背景从白色更改为另一种颜色,然后以缓慢淡入的方式再次返回白色。 i have tried the animate it simply doesn't work. 我试过动画它根本不起作用。 there is no error. 没有错误。
<script type="text/javascript" src="/jsp/ui/jquery-ui/js/jquery-1.8.3.min.js"></script>
...
$(document.getElementById(id)).animate({ backgroundColor: "#4E1402" }, 500);
update 更新
This works fine 这很好用
$(document.getElementById(id)).animate({ width: "400px" }, 500);
jQuery cannot animate color. jQuery无法为颜色设置动画。 Use this plugin instead. 请改用此插件。
http://www.bitstorm.org/jquery/color-animation/ http://www.bitstorm.org/jquery/color-animation/
( just a 4kb addition ) (仅增加4kb)
Or the jquery UI animate : 或者jquery UI动画:
http://jqueryui.com/animate/ ( as mentioned by @Adam below ) http://jqueryui.com/animate/ (如下面的@Adam所述)
你需要这个插件来使用jQuery为颜色设置动画: http : //archive.plugins.jquery.com/project/color
Have you included jquery-ui library as well? 你也包括jquery-ui库吗?
If I remember good, current element that you are reffering to, must have some background color set at start. 如果我记得你正在做的好的当前元素,必须在开始时设置一些背景颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.