0

I have this "for" loop that calls a function for ids named b1,b2,b3

for (var i = 1; i <= 3; i++) {
        editorfunction("b" + i);
        }

But the effect of this code need to be run with intervals of time. That means after editorfunction affects b1, there should be 1 second time space and then the action should be applied for b2, like that.

I tried this

for (var i = 1; i <= 3; i++) {
        //editorfunction("b" + i);
        setInterval(function () {editorfunction("b" + i);}, 1000; }
        }

But it does not work. How can I make it work?

nimala9
  • 201
  • 1
  • 2
  • 6
  • The answer below gives you `1000*i` which is correct, but then you're going to encounter the second problem, which the duplicate explains. – elclanrs Sep 18 '14 at 18:50
  • 1
    @elclanrs This question is not a duplicate of the one you proposed, and the answer below has since been deleted. – JLRishe Sep 18 '14 at 18:56
  • I see a clear dup... here's another one http://stackoverflow.com/questions/6425062/passing-functions-to-settimeout-in-a-loop-always-the-last-value. OP wants `setTimeout` probably. – elclanrs Sep 18 '14 at 19:01
  • @elclanrs That second one is a lot more apropos. The original you used only answers a portion of OP's problem, as you yourself alluded. – JLRishe Sep 18 '14 at 19:17

0 Answers0