【发布时间】:2012-03-02 15:43:03
【问题描述】:
我想用这个来突出一个元素:
$('input.step:last').css('background','#003').animate({'background':'#fff'},300);
但它不起作用。
为什么?
【问题讨论】:
标签: jquery css jquery-animate
我想用这个来突出一个元素:
$('input.step:last').css('background','#003').animate({'background':'#fff'},300);
但它不起作用。
为什么?
【问题讨论】:
标签: jquery css jquery-animate
要为颜色设置动画,您需要添加 jQuery Animate Colors 插件。
http://www.bitstorm.org/jquery/color-animation/
那么,你应该使用:
$('input.step:last').css('background-color','#003')
.animate({'background-color':'#fff'},300);
请注意,您应该为“背景颜色”属性而不是“背景”属性设置动画。
【讨论】:
您需要JQuery.Color 插件(jquery-ui 的一部分)。然后做,
$(document).ready(function(){
$('input.step:last')
.css({'backgroundColor':'#003'})
.animate({'backgroundColor':'#fff'},300);
})
【讨论】:
默认情况下,jQuery can’t animate colors。您可以使用jQuery.color() plugin, found here, 赋予它该功能。
【讨论】: