Created
July 4, 2022 06:07
-
-
Save thamognya/5f45ed88141feb9faea693e2efcde9e5 to your computer and use it in GitHub Desktop.
A simple html + js counter
This file contains 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"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Counter</h1> | |
<button id="mainButton">Increment Num</button> | |
<p id="number">0</p> | |
<script> | |
let counter = document.getElementById("number"); | |
let counterNum = Number(counter.innerText); | |
let button = document.getElementById("mainButton"); | |
button.addEventListener("click", () => { | |
counter.innerText = counterNum++; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment