为什么动画和 addClass 的行为不同?
我有一个 div,其初始颜色为绿色。
我不明白为什么他立即获得红色颜色**,
而动画在队列中正常。
队列正常并且按顺序
,但是颜色立即更改。
他不是应该在第二个动画之后吗?
动画优先级与 addClass 之间有区别吗?
$("div").show("slow").animate({left:'+=200'},2000).animate({top:'+=200'},2000).css('background-color','red');
I have a div which its initial color is green.
I don't understand why he is getting the red color ** immediately** ,
while the animations are fine in queue.
The queue is fine and by order
, but the color is changed immediatly.
Isn't he supposed to be after the second animation ?
Is there difference between priority of animations vs addClass ?
$("div").show("slow").animate({left:'+=200'},2000).animate({top:'+=200'},2000).css('background-color','red');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
css
方法不会将更改放入动画队列,因此当您运行代码时它会立即更改。您可以使用
queue
方法将 CSS 更改放入动画队列中:The
css
method doesn't put the change on the animation queue, so it's changed immediately when you run the code.You can put the CSS change in the animation queue using the
queue
method:css 不是排队函数。它立即执行。您可以选择:
和
css isn't a queued function. It executes immediately. You can choose between:
and
请原谅我的缩进。
Excuse my indenting.