$("#maincontent").animate({"top":"450px"},1200)
.html($("#"+Lidentity).html())
.animate({"top":"0px"},1000);
friend 们大家好,
这是 jquery 代码,运行良好。如
1. 将 maincontent 顶部动画设置为 450px
2. 获取内容并放入 maincontent
3. 再次将 maincontent 顶部动画设置为 0px。
这将产生类似于幻灯片的效果。
我的问题是什么?这些不是按顺序出现的。它只是按照 2 1 3 的顺序工作
我需要按1 2 3 顺序。我怎样才能实现它。
br> 请帮助我
谢谢,
Praveen J
最佳答案
您需要在 animate() 回调中将调用链接在一起,即:
$("#maincontent").animate({
top: "450px"
}, 1200, function() {
$(this).html($("#"+Lidentity).html()).animate({
top: "0px"
}, 1000);
});
当然,您可以使用函数来简化它:
$("#maincontent").animate({"top":"450px"}, 1200, after_move);
function after_move() {
$(this).html($("#"+Lidentity).html()).animate({
top: "0px"
}, 1000);
});
如果有帮助的话。
关于jquery - jquery中如何使函数按顺序排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1068782/