JavaScript sleep/wait before continuing [duplicate]

I have a JavaScript code that I need to add a sleep/wait function to. The code I am running is already in a function, eg:

function myFunction(time)
{
    alert('time starts now');
    //code to make the program wait before continuing
    alert('time is up')
}

I have heard that a possible solution might include

setTimeout

but I am not sure how to use it in this case.

I can’t use PHP, as my server does not support it, although using jQuery would be fine.

1 Answer
1

Leave a Comment