[英]how to call function after timeout function is done?
I have a function with a timer, I want to call another function when the timer of the another function is done, so the first function will show a modal for 3 seconds, and the another funciton will show another modal, here is my code: 我有一个带计时器的函数,我想在另一个函数的计时器完成后调用另一个函数,因此第一个函数将显示一个模态持续3秒钟,另一个函数将显示另一个模态,这是我的代码:
var fn = setTimeout(function(){
$('#responseModal').modal('hide');
return true;
}, 3000);
if(fn)
$('#requestModal').modal('show');
Wouldn't 岂不
setTimeout(function(){
$('#responseModal').modal('hide');
$('#requestModal').modal('show');
}, 3000);
do the trick? 绝招?
No need to return anything in the callback function for setTimeout
. 无需在setTimeout
的回调函数中返回任何内容。 It's meaningless. 没有意义的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.