jQuery animate根本不起作用
jQuery animate not working at all
我想在DOM ready上设置一个背景色div属性,然后执行一些动画,比如$("#test").css('background-color','red').animate({ 'background-color' : '#FFF'}, 500);
。Div看起来像这个<div id="test">11</div>
,并且在CSS文件#test{
background-color:#FFF;
}
中设置了背景色属性
现在的问题是,为什么动画不起作用?你可以在这里看到代码-http://jsfiddle.net/hzdcM/
您需要包含jQuery UI,以使您的背景色动画工作
演示-->
http://jsfiddle.net/hzdcM/1/
因为jQuery本身不能动画化颜色,所以在jQuery插件中搜索该
.animate()
函数不支持设置颜色动画。使用jQuery颜色插件。或者您可以使用jQuery UI库。
UI库仅用于颜色使用就非常繁重。
此外,您必须使用backgroundColor
而不是background-color
来正确地设置颜色的动画。
$("#test")
.css('backgroundColor','red')
.animate({ 'backgroundColor' : '#FFF'}, 500);
相关文章:
- $animate addClass在angular 1.3中不起作用
- jQuery Animate 在创建图库滑块时不起作用
- css animate fadeIn'对我来说不起作用
- Javascript/JQuery .animate() 不起作用
- $animate.removeClass 在没有 $evalAsync inside 指令的情况下不起作用
- jQueryUI animate(color) 不起作用
- $(“html”).animate 不起作用
- JS .animate() 在 Firefox/IE 中不起作用
- css JQuery animate 不起作用
- Jquery ui animate 函数不起作用
- jQuery animate:scrolltop 在 Firefox 或 Web Explorer 中不起作用
- jQuery animate() 在 Chrome 中不起作用
- jquery Animate 在 IE9 及更早版本中不起作用
- remove() 方法在 animate() 中不起作用
- jQuery animate() pulse() 不起作用
- JQuery animate获胜'不起作用
- Jquery.animate 100%高度不起作用
- 当从外部方法调用时,RaphaelJS的animate不起作用
- Jquery .animate()用于左右滚动在Firefox中不起作用,但在Chrome中很好
- jQuery animate根本不起作用