Javascript JQuery CSS动画
我很难让这个动画工作Javascript JQuery CSS动画,javascript,jquery,css,animation,Javascript,Jquery,Css,Animation,我很难让这个动画工作 $("#selectedTime").stop().animate({ "margin-left": "-=470px" },"fast", function() { $(this).css({ "margin-left": "620px" })}).animate({ "margin-left": "-=470px" },"fast"); 我将div向左滑动470px,跳到620px,再向左滑动另一个470px$css({“marginLeft”
$("#selectedTime").stop().animate({
"margin-left": "-=470px"
},"fast", function() {
$(this).css({ "margin-left": "620px"
})}).animate({
"margin-left": "-=470px"
},"fast");
我将div向左滑动470px,跳到620px,再向左滑动另一个470px$css({“marginLeft”:“620px”似乎不起作用
初始左边距为150px。运行脚本后为-790px。(150-470-470)。首先,出现语法错误:
$("#selectedTime").stop().animate({
"margin-left": "-=470px"
},"fast", function() { // ↓↓↓ here
$(this).css({ "margin-left": "620px"});
}).animate({
"margin-left": "-=470px"
},"fast");
演示:您遇到了什么问题?-=,您尝试过简单地使用-470px吗?其他CSS应用于
#selectedTime
?同样的问题。仍然以-790px结束。很漂亮。我想这应该是一个动画,但我没有想到将持续时间设置为0。谢谢!!不客气。您介意吗
$("#selectedTime")
.stop()
.animate({"margin-left": "-=470px"}, "fast")
.animate({"margin-left": "620px"}, 0)
.animate({"margin-left": "-=470px"}, "fast");