how to make a sleep in javascript?

后端 未结 9 2042
半阙折子戏
半阙折子戏 2020-12-20 23:00

Does anyone know how can I make a sleep in javascript before next line been read by the system?

example:

    1 var chkResult = Validation();
    2 /         


        
9条回答
  •  情歌与酒
    2020-12-20 23:43

    The delay won't happen until JavaScript has relinquished control back to the browser, so your line 4 will execute before the setTimeout starts.

    You should be making everything happen based on events.

提交回复
热议问题