Hi,
I want to do some task after regular interval, lets say I want to do something every second or every minute or hour?
Is it possible in JavaScript?
Hi makenzi.exc,
The setInterval method calls a function at specified intervals (in milliseconds) which will be used to repeat a task at some interval.
Refer below example.
HTML
<html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <label id="lblMessage"></label> <script type="text/javascript"> window.onload = function () { var i = 60; setInterval(function () { // Set Label every 1 second. document.getElementById("lblMessage").innerHTML = "Remaining Time " + i + " seconds"; i--; }, 1000); }; </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.