-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGETTING
More file actions
43 lines (35 loc) · 920 Bytes
/
GETTING
File metadata and controls
43 lines (35 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<title>Counter Program</title>
</head>
<body>
<h1>Counter Program</h1>
<p id="count">0</p>
<button id="increment">Increment</button>
<button id="decrement">Decrement</button>
<script>
// Get references to the HTML elements
const countElement = document.getElementById("count");
const incrementButton = document.getElementById("increment");
const decrementButton = document.getElementById("decrement");
let counter = 0;
// Update the counter display
function updateCounterDisplay() {
countElement.textContent = counter;
}
// Increment the counter
incrementButton.addEventListener("click", function() {
counter++;
updateCounterDisplay();
});
// Decrement the counter
decrementButton.addEventListener("click", function() {
counter--;
updateCounterDisplay();
});
// Initial display
updateCounterDisplay();
</script>
</body>
</html>