简体   繁体   中英

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:

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 . It's meaningless.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM