You can use setInterval()
, the arguments are the same.
const interval = setInterval(function() {
// method to be executed;
}, 5000);
clearInterval(interval); // thanks @Luca D'Amico
More Related Contents:
- Is it possible to simulate key press events programmatically?
- JavaScript click event listener on class
- onKeyPress Vs. onKeyUp and onKeyDown
- How can I get the scrollbar position with JavaScript?
- How to find out what character key is pressed?
- How can I capture the right-click event in JavaScript? [duplicate]
- Wait 5 seconds before executing next line
- How do I capture response of form.submit
- Manipulating innerHTML removes the event handler of a child element? [duplicate]
- How to pass parameter to function using in addEventListener?
- How do you log all events fired by an element in jQuery?
- Javascript trick for ‘paste as plain text` in execCommand
- Are there any standards for mobile device web browsers in terms of thread sleeping? [closed]
- JavaScript mapping touch events to mouse events
- Capture click on div surrounding an iframe
- Using this inside an event handler
- Native JS equivalent to jQuery delegation
- Are event handlers in JavaScript called in order?
- HTML DOM: Which events do not bubble?
- Javascript onkeydown event fire only once?
- Can multiple event listeners/handlers be added to the same element using Javascript?
- onchange event not fire when the change come from another function
- Looping through files for FileReader, output always contains last value from loop
- How to check whether a Button is clicked by using JavaScript
- event.clipboardData.setData in copy event
- Is there any way of passing additional data via custom events?
- Is event a global variable that is accessible everywhere inside the callback chain?
- JavaScript: How to simulate change event in internet explorer (delegation)
- Detecting user inactivity over a browser – purely through javascript [duplicate]
- In web browsers, what’s the difference between onblur and onfocusout?