Last active
March 12, 2021 06:38
-
-
Save bogoreh/9c1f40230752f06cdce1a2d5f764235e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Spin-off of "Challenge: Stopwatch"</title> | |
| </head> | |
| <body> | |
| <button id="stop-button" type="button">Stop</button> | |
| <p> | |
| <span id="seconds">0</span> seconds have gone by! | |
| </p> | |
| <script> | |
| // Make it count up on a timer, calling this function | |
| var seconds = document.getElementById("seconds"); | |
| var countUp = function() { // ? | |
| seconds.textContent = parseFloat (seconds.textContent) + 1; | |
| }; | |
| var timer = window.setInterval(countUp, 1000); | |
| // How can you make it stop counting? | |
| var stopCountUp = function() { | |
| window.clearInterval(timer); | |
| }; | |
| var stopButton = document.getElementById("stop-button"); | |
| stopButton.addEventListener("click", stopCountUp); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment