In this article, the following function is given to perform an operation x times with setInterval()
setIntervalX(function () {
animateColor();
//or something
}, 3000, 4);
function setIntervalX(callback, delay, repetitions) {
var x = 0;
var intervalID = window.setInterval(function () {
callback();
if (++x === repetitions) {
window.clearInterval(intervalID);
}
}, delay);
}
what does the callback() do here? I'm trying to do a function after the specified number of repetitions is complete. but this
setIntervalX(function () {
animateColor();
}, 3000, 4, function(){
completeFunction();
});
does not work. Perhaps that syntax is very wrong. I was under the impression that using jquery, you could string together functions like that..
Much grateful for any insight. Thanks!