calling setTimeout with a for loop

前端 未结 3 1738
遇见更好的自我
遇见更好的自我 2021-01-21 00:25

I\'ve written a function that changes the css positioning of a div

I\'ve been successfully using setTimeout to call the function at a specific interval

NOW what

3条回答
  •  长发绾君心
    2021-01-21 00:33

    My approach to these self calling functions.

    var i = -1;
    (function cssPositioning() {
      i++;
      if ( i < 28 ) {
                changeDirection(divlist[i]);
        setInterval(cssPositioning, divs[divlist[i]].speed);
      }
    })();
    

提交回复
热议问题