gpt4 book ai didi

javascript - JQuery CSS 动画

转载 作者:太空宇宙 更新时间:2023-11-04 16:21:09 25 4
gpt4 key购买 nike

我无法让这个动画正常工作。

$("#selectedTime").stop().animate({
"margin-left": "-=470px"
},"fast", function() {
$(this).css({ "margin-left": "620px"
})}).animate({
"margin-left": "-=470px"
},"fast");

我将 div 向左滑动 470px,跳到 620px 并向左滑动另一个 470px。 $(this).css({ "marginLeft": "620px"似乎不起作用。

初始 margin-left 为 150px。运行脚本后它是-790px。 (150-470-470)。

最佳答案

首先,你有语法错误:

$("#selectedTime").stop().animate({
"margin-left": "-=470px"
},"fast", function() { // ↓↓↓ here
$(this).css({ "margin-left": "620px"});
}).animate({
"margin-left": "-=470px"
},"fast");

$("#selectedTime")
.stop()
.animate({"margin-left": "-=470px"}, "fast")
.animate({"margin-left": "620px"}, 0)
.animate({"margin-left": "-=470px"}, "fast");

演示:http://jsfiddle.net/mattball/j7rcr/

关于javascript - JQuery CSS 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6557351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com