2012-02-24 200 views
0

目前我使用此代码为动画回到原来的状态.animate返回到原来的状态

this.stop().animate(animateVal1, animateMs).delay(duration).animate(animateVal2, animateMs, function() { 
    this.removeAttribute('style'); 
}); 

是不是可以不褪色到第二色animateVal2恢复回原来的状态? (我的意思是动画,以第一种颜色后,我想删除style动画属性。)

回答

0

这是我从你的问题理解:

你有一个元素X,这是在国家A(由于一些来自CSS规则的应用类)。

你想制作动画陈述B,使用jquery.animate(),而是希望将其恢复到原来的状态A。但是,在执行动画功能时,您没有包含A的所有属性的Javascript对象。

为此,我建议您使用jQuery UI的switchClass函数。

this.stop().switchClass('classB', animateMs).delay(duration).switchClass('originalClass', animateMs);