Setinterval() Not Working
I am trying to run a function at setInterval() of '1 second', but it is a bit problematic. I have done everything as shown here but it doesn't work. Here is my code :
Solution 1:
into setInterval
function's first parameter you should pass a function or an anonymous function like
setInterval(function(){
console.log("1s delayed")
},1000);
Solution 2:
As said before, first argument should be the function:
var self = $(this);
var inter = function() {
self.html(time_ago(time_r));
}
setInterval(inter, 1000);
Solution 3:
var self = this;
setInterval(function(){
$(self).html(time_ago(time_r));
},1000);
Solution 4:
Have a look here : window.setInterval
window.setTimeout( function() { /*your code which you want to execute after fixed interval, it can function name or lines of code*/}, /*fixedInterval*/);
window.setTimeout( function() { alert("Hello World!"); }, 5000); // it will execute after 5 seconds
Post a Comment for "Setinterval() Not Working"