set time out not working with function

前端 未结 4 1803
予麋鹿
予麋鹿 2021-01-20 03:23

I am using the following to pause the javascript for a few seconds:

 setTimeout(start_countdown(),3000);

It does not work, the function is

4条回答
  •  臣服心动
    2021-01-20 04:13

    write instead

    setTimeout(start_countdown, 3000);
    

    without parens ()
    the second example could be also written as

    setTimeout(function() { alert('hi'); }, 3000);
    

提交回复
热议问题