我有2个函数abc()和def()。两者都有settimeout功能。它们是从父xyz()函数调用的。最初应该在调用abc动画def()函数之后调用abc()。问题:两个函数都是一个接一个地调用,但它们之间没有延迟.settimeout同时工作。请帮忙。提前谢谢。
function abc() {
// there is settimeout function
//cleartimeout after some time
}
function def() {
// there is settimeout function
//cleartimeout after some time
}
function xyz() {
abc(); // i need a delay between each settimeout functionality.
def(); //currently both run together.
}
答案 0 :(得分:1)
一种解决方案是在xyz()
function abc() {
// Leave this alone, no need for setTimeout in here
}
function def() {
// Leave this alone, no need for setTimeout in here
}
function xyz() {
abc(); // i need a delay between each setTimeout functionality.
setTimeout(def, 500);
}
如果def()
之后abc()
总是,那么您可以xyz()
致电abc()
,abc()
可以致电def()
动画结束后abc()
,但我们需要查看{{1}} =)的代码