Running functions after delay with setInterval - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setInterval

Description

Running functions after delay with setInterval

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// w w w  . j  a v a 2s.c  om
function funcOne() {
    console.log('one');
}
function funcTwo() {
    console.log('two');
}
function funcThree() {
    console.log('three');
}
var i = 0;
var funcs = [ funcOne, funcTwo, funcThree ];
setInterval(function() {
    funcs[i % funcs.length]();
    i++;
}, 2000);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials