Last active
October 31, 2019 22:08
-
-
Save dominem/bdddf00aa294eb8d6e0055289707f300 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<div id="counter"></div> | |
<button id="start">Start</button> | |
<script> | |
let counter = 60; | |
let interval = null; | |
let counterElement = document.getElementById('counter'); | |
let startElement = document.getElementById('start'); | |
init(); | |
function init() { | |
counterElement.innerText = counter; | |
startElement.onclick = count; | |
} | |
function subtract() { | |
counter -= 1; | |
console.log(counter); | |
counterElement.innerText = counter; | |
} | |
function count() { | |
interval = setInterval(subtract, 1000); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@elzbietamal95 Here!