www.webdeveloper.com
Results 1 to 2 of 2

Thread: Create a JavaScript sleep/wait function

Hybrid View

  1. #1
    Join Date
    Jun 2013
    Posts
    1

    Create a JavaScript sleep/wait function

    Hi,
    I was wanting to create a JavaScript function in which I could tell the script to wail or sleep, such as
    Code:
    function sleepNow(time)
    {
    //sleep for time
    }
    With this, I could then call it at any point in the script, such as
    Code:
    sleepNow(4000);
    or
    Code:
    <input type="button" onclick="sleepNow(1000);">
    Is this possible?
    I would prefer it to be just JavaScript, but I do not mind other JavaScript libraries such as jQuery.
    Thanks in advance

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    Yes It is ! See setTimeout

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles