Mail your problems to us on lawania@lavania.in, we will solve it and put the solution here at Lawania.com

Simple digital stop watch in Javascript

A script to display simple stop watch Click to Test






<!DOCTYPE html>
<html>
<body onload="ts()">

<p>A script to display simple stop watch</p>

<p id="demo"></p>
<button onclick="ts()">Start time</button>
<button onclick="clearInterval(myVar)">Stop time</button>

<script>
 s = 0;
 m = 0;
 h = 0;
function ts()
{

myVar = setInterval(function(){myTimer()},1000);
function myTimer() {
   
    if(s<10)
s = "0"+s;
    document.getElementById('demo').innerHTML = h+":"+m+":"+s;
s++;
    if ( s==60)
{
m++;
if( m==60)
{
h++;
if(h==24)
{
h=0;
}
m=0;
}

s = 0;
}
}
}
</script>

</body>
</html>







Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment