JQuery:内容加载不等待动画完成
$("#clickme").click(
function(){
$(this).slideToggle(1000);
$(this).load("MYTEXT.txt");
$(this).slideToggle(1000);
}
)
我希望仅在第一个动画完成后才显示 HTML 元素的新内容。这段代码发生的情况是,它先向上滑动,然后向下滑动新内容,但是新内容是在向上滑动效果完成之前显示的!
我该如何解决这个问题?
$("#clickme").click(
function(){
$(this).slideToggle(1000);
$(this).load("MYTEXT.txt");
$(this).slideToggle(1000);
}
)
I want the new content of my HTML element to be displayed ONLY after the first animations is finished. What happens in this code is, it first slides up, and slides down with new content, but the new content is shown before the slide up effect is done!
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了让事情先后发生,您可以使用回调仅在前一个函数运行后运行代码(这对于动画和 AJAX 调用非常有用)。
To get things to happen after eachother, you can use callbacks to run code only after the previous function has run (which is very useful for animations and AJAX calls).
您必须将它们作为回调链接起来
You will have to chain them as callbacks
试试这个:
try this: