There are several problems with your code. First, you're executing b() c() and d() immediately rather than on each interval. Additionally, b() c() and d() are NOT causing any kind of animation, therefore the for loops are completely pointless. Then, your for loop at the end wrapping the interval is not necessary.
var a = [b, c, d];
function b() {
document.getElementById("ok").style.left = 700000 + "px";
console.log(700000);
}
function c() {
document.getElementById("ok").style.left = 20 + "px";
console.log(20);
}
function d() {
document.getElementById("ok").style.left = 5 + "px";
console.log(5);
}
var i = 0;
setInterval(function () {
a[i]();
i++;
if (i == a.length) {
i = 0;
}
}, 1000);
A basic css transition will add the animation:
And here it is simplified:
var a = [700000, 20, 5];
function setLeftStyle(position) {
document.getElementById("ok").style.left = position + "px";
console.log(position);
}
var i = 0;
setInterval(function () {
setLeftStyle(a[i]);
i++;
if (i == a.length) {
i = 0;
}
}, 1000);