-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (33 loc) · 907 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var hours =0;
var mins =0;
var seconds =0;
$('#start').click(function(){
startTimer();
});
$('#stop').click(function(){
clearTimeout(timex);
});
$('#reset').click(function(){
hours =0; mins =0; seconds =0;
$('#hours','#mins').html('00:');
$('#seconds').html('00');
});
function startTimer(){
timex = setTimeout(function(){
seconds++;
if(seconds >59){seconds=0;mins++;
if(mins>59) {
mins=0;hours++;
if(hours <10) {$("#hours").text('0'+hours+':')} else $("#hours").text(hours+':');
}
if(mins<10){
$("#mins").text('0'+mins+':');}
else $("#mins").text(mins+':');
}
if(seconds <10) {
$("#seconds").text('0'+seconds);} else {
$("#seconds").text(seconds);
}
startTimer();
},1000);
}