我要将物体向上移动,延迟1000毫秒,然后隐藏它,
我得到了代码:
$("#test").animate({"top":"-=80px"},1500)
.animate({"top":"-=0px"},1000)
.animate({"opacity":"0"},500);
我用".animate({"top":"-=0px"},1000)“来实现延迟,它不太好。
我想要:
$("#test").animate({"top":"-=80px"},1500)
.sleep(1000)
.animate({"opacity":"0"},500);
有什么想法吗?
发布于 2010-05-31 03:33:25
那.delay()
呢?
$("#test").animate({"top":"-=80px"},1500)
.delay(1000)
.animate({"opacity":"0"},500);
发布于 2010-05-31 04:42:57
如果你不能像Robert Harvey建议的那样使用delay
方法,你可以使用setTimeout
。
例如:
setTimeout(function() {$("#test").animate({"top":"-=80px"})} , 1500); // delays 1.5 sec
setTimeout(function() {$("#test").animate({"opacity":"0"})} , 1500 + 1000); // delays 1 sec after the previous one
https://stackoverflow.com/questions/2939980
复制相似问题