Created
December 16, 2023 12:56
-
-
Save amitroy06/f0e25e9e5b1d7e99a67f88d6c5c6f936 to your computer and use it in GitHub Desktop.
number
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"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Number <span id="start">0</span></h1> | |
<button id="max">+</button> | |
<button id="min">-</button> | |
<script src="main.js"></script> | |
</body> | |
</html> |
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
const zero = document.getElementById("start"); | |
const high = document.getElementById("max"); | |
const low = document.getElementById("min"); | |
let number = 0; | |
const changeNumber = () => { | |
zero.textContent = number; | |
}; | |
high.addEventListener("click", () => { | |
number += 1; | |
changeNumber(); | |
}); | |
low.addEventListener("click", () => { | |
number -= 1; | |
changeNumber(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment