using setTimeout synchronously in JavaScript

后端 未结 9 1733
无人及你
无人及你 2020-12-02 12:40

I have the following scenario:

setTimeout(\"alert(\'this alert is timedout and should be the first\');\", 5000);
alert(\"this should be the second one\");
         


        
9条回答
  •  死守一世寂寞
    2020-12-02 13:42

    Just put it inside the callback:

    setTimeout(function() {
        alert('this alert is timedout and should be the first');
        alert('this should be the second one');
    }, 5000);
    

提交回复
热议问题