diff --git a/index.html b/index.html index c1129f7..4ab73ca 100644 --- a/index.html +++ b/index.html @@ -10,11 +10,13 @@

Stop Watch

- - - + + +
+ + diff --git a/style.css b/style.css index 6ddb643..f25cefb 100644 --- a/style.css +++ b/style.css @@ -27,4 +27,3 @@ button { button:hover{ background: #356094; } - diff --git a/timers.js b/timers.js index fd40910..b27f3b2 100644 --- a/timers.js +++ b/timers.js @@ -1,4 +1,28 @@ +let reset = document.getElementById('reset'); +let start = document.getElementById('start'); +let pause = document.getElementById('pause'); +let seconds = 0; +let timerId; +function updateTime(){ + document.getElementsByTagName('h1')[0].innerHTML=seconds; + seconds++;} + +start.addEventListener('click', function() { + startCount = setInterval(updateTime, 1000); +}); + + +pause.addEventListener('click', function() { + clearInterval(startCount); +}); + + +reset.addEventListener('click', function(){ + seconds = 0; + clearInterval(startCount); + document.getElementsByTagName('h1')[0].innerHTML= "Stop Watch"; +});