Created
February 21, 2014 16:11
-
-
Save scriptnull/9137105 to your computer and use it in GitHub Desktop.
My approach of writing a js timer !
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Timer</title> | |
<script type="text/javascript"> | |
function onloadME (timer) { | |
window.setInterval(timerfunc,1000); | |
} | |
sec = 0 ; | |
min = 0; | |
hour = 0; | |
var timerfunc = function(){ | |
sec++; | |
timer.innerHTML = hour + " : " + min + " : " + sec ; | |
if(sec==60) | |
{ | |
sec=0 ; | |
min++; | |
timer.innerHTML = hour + " : " + min + " : " + sec ; | |
if(min == 60) | |
{ | |
min=0; | |
hour++; | |
timer.innerHTML = hour + " : " + min + " : " + sec ; | |
} | |
} | |
} | |
</script> | |
</head> | |
<body onload="onloadME(timer)"> | |
<p id="timer">Timer Appears Here !</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment