[英]JQuery animation effects immediately revert after animation
I feel like I am going crazy here.我觉得我在这里要疯了。 I am playing around with JQuery animation.
我正在玩 JQuery animation。 Something I haven't really used since school.
我从学校开始就没有真正使用过的东西。
I am doing something super simple.我正在做一些超级简单的事情。 I have a div that is just a square that is 150px by 150px I am using JQuery to animate it to grow the width.
我有一个 div,它只是一个 150px x 150px 的正方形,我正在使用 JQuery 对其进行动画处理以增加宽度。 As soon as the animation completes, the square reverts back to the original dimensions.
一旦 animation 完成,正方形就会恢复到原始尺寸。
Now I seem to remember that the animation effects would stay changed once the animation completes.现在我似乎记得,一旦 animation 完成,animation 效果将保持不变。 Has this changed?
这有改变吗? Or am I simply misremembering how this works?
还是我只是记错了这是如何工作的? All the examples I have seen on W3 schools and such have the animation stay once it is complete.
我在 W3 学校中看到的所有示例等在完成后都会保留 animation。
#square
{
width: 150px;
height: 150px;
background-color: red;
margin:10px;
}
$("#square").click(function(){
(this).animate({width:"400px"}, 2000);
});
use $(this) that's the problem:使用 $(this) 这就是问题所在:
$("#square").click(function(){
$(this).animate({width:"400px"}, 2000);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.