OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
Simple way to count the time up to infinite in JavaScript | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Home » Articles » Simple way to count the time up to infinite in JavaScript
Simple way to count the time up to infinite in JavaScript
Article Posted On Date : Saturday, March 24, 2012
Simple way to count the time up to infinite in JavaScript
Advertisements
Introduction: How will you count the time of timer up to infinite, and how to stop that time in java script? To find the answer of these questions learn this article. Here we will use two functions one is timedcount() for counting the time up to infinite and another is stopcount() for stop the time. There are two methods used in JavaScript. setTimeout () clearTimeout () Example: <html> <head> <title>TimeCount and StopCount</title> </head> <script type="text/javascript"> var a=0 var x function timedCount() { document.getElementById('txt').value=a a=a+1 x=setTimeout("timedCount()",1000); } function stopCount() { clearTimeout(x) } </script> <body> <form> <input type="button" value="Start count!" onClick="timedCount()"> <input type="text" id="txt"> <input type="button" value="Stop count!" onClick="stopCount()"> </form> <p><font color="Green"> click on 'Start count' button to time count forever.</font></p> <p><font color="red">click on 'Stop count' button to stop the counting.</font></p> </body> </html> In this example two methods are used, one is setTimeout and another is clearTimeout. By using setTimeout method counting will start from zero. Here we have to set delaytime=1000 millisecond=1 second, so the time interval is one second. By using the clearTimeout method counting will stop.
Amazon.in Widgets