using setTimeout synchronously in JavaScript

后端 未结 9 1727
无人及你
无人及你 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:45

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

提交回复
热议问题