Home > jQuery > How to Call a Function Every X Seconds in jQuery
Bookmark and Share

How to Call a Function Every X Seconds in jQuery

Posted on March 27, 2018 | Filed in jQuery

A lot of times when a page is loaded, you will want to wait to do anything until the user interacts with an element, like submitting a form. Other times, you will want an event to happen every X seconds. To do this, you would use:

window.setInterval(function(){
// Put your code here
}, 5000);

It is important to note that the interval is set to 5000. It is calculated in milliseconds, so 5000 would actually be 5 seconds.

Leave a Reply

Contact Us

Big Apple Design Group
134 West 29th Street
Third Floor
New York, NY 10001

[email protected]

Search Blog