Create wait method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setInterval

Description

Create wait method

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. ja  va  2s. c  o m*/
var count = 1;
time = setInterval(function(){
    document.getElementById("label1").innerHTML="Indio: " + count;
    count+= 1;
    if (count == 5)
    {
        clearInterval(time);
    }
},6000);
    }

      </script> 
   </head> 
   <body> 
      <label id="label1" class="test">Indio: 0</label>  
   </body>
</html>

Related Tutorials