setInterval | References Javascript | Javascript | centre-equestre-lepuy.com ..


Sponsored Links

setInterval

The setInterval () method allows you to run the code statements in a periodic manner (creating, ie, a loop) at an interval of time. The code execution will stop only when they will run the clearInterval () method.

The syntax is similar to that of setInterval setTimeout () .

Let's see an example of using structured setInterval () and clearInterval ():






 <input type="text" id="orologio" />







 <script language=javascript>







 var int = self.setInterval ("clock ()", 1000);







 clock function () {



  



 var d = new Date ();



  



 var t = d.toLocaleTimeString ();



  



 document.getElementById ("clock"). value = t;







 }







 </ Script>







 </ Form>







 <button onclick="int=window.clearInterval(int)"> Stop </ button>



In our example the ethod setInterval () is used to update each time viewed within seconds of a clock which can be stopped by clicking on the button.

In the same category ...
E-Learning
CSS (Course) CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €.
HTML (Course) HTML (Course)
The markup language for the Web from 29 €.
Javascript (Course) Javascript (Course)
Complete guide to client-side scripting. From 39 €.
Sponsored Links