Today in this post we are going to share, How to make a function that can run every second or run in every specific second in Javascript.

This is very simple and easy to implement. It is very useful if you want to run any block of code every second.

Also attaching a brief explanation video for running a function at a specific time interval.

First, you need to make a simple function and add the codes to whatever you want to do. Then use the “setInterval()” predefined function with its parameter, In the below paragraph, given the example of calling the setInterval function.

    <h1>Use of <b style="color:red">setInterval</b> function</h1>
    <p id="display"></p>

    setInterval(counter, 1000);
    var i=1;
    function counter(){
    document.getElementById("display").innerHTML +=i+"<br>";



How to call a function every 10 seconds javascript

Leave a Reply

Your email address will not be published.