Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timer() {
- let tick = 0;
- let clockOn=false;
- let myInterval = null;
- function step() {
- tick++;
- let seconds = ('0' + tick % 60).slice(-2);
- $('#seconds').text(seconds);
- let minutes = ('0' + Math.floor(tick / 60)).slice(-2);
- $('#minutes').text(minutes);
- let hours = ('0' + Math.floor(minutes / 60)).slice(-2);
- $('#hours').text(hours);
- }
- function myStopFunction() {
- clearInterval(myInterval);
- console.log('clear');
- }
- $('#start-timer').on('click', function(){
- myInterval = setInterval(step, 1000);
- });
- $('#stop-timer').on('click', myStopFunction);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement