call function time interval jquery code example

Example 1: jquery call function every second

setInterval(function(){ 
    //this code runs every second 
}, 1000);

Example 2: javascript setinterval

setInterval(function(){ 
	console.log("Oooo Yeaaa!");
}, 2000);//run this thang every 2 seconds

Example 3: javascript interval fixed number of times

var x = 0;
var intervalID = setInterval(function () {

   // Your logic here

   if (++x === 5) {
       window.clearInterval(intervalID);
   }
}, 1000);

Example 4: javascript setinterval

setInterval(function(){ 
	console.log("print this once every 3 second");
}, 3000);//run this thang every 3 seconds