0   0

Call a JavaScript Function at Regular Intervals

By Rahul Tiwary Blogs | JavaScript Mar 31, 2013
Call a JavaScript Function at Regular Intervals | Execute Function Every n Seconds.
Here I will explain how to call a JavaScript function at regular intervals of time or run/execute JavaScript function every 10 seconds or execute JavaScript function at specific time in

<html xmlns="">
<title>Run JavaScript function at specific intervals of time</title>
<script type="text/javascript">
var count=0;
function changeColor() {

// Call function with 500 milliseconds gap
setInterval(starttimer, 500);
function starttimer() {
count += 1;
var oElem = document.getElementById("divtxt"); = == "red" ? "blue" : "red";
document.getElementById("lbltxt").innerHTML = "Your Time Starts: "+count;
<div id="divtxt">
<label id="lbltxt" style="font:bold 24px verdana" />
<button onclick="changeColor();">Start Timer</button>


Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs