-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter.html
More file actions
28 lines (24 loc) · 744 Bytes
/
counter.html
File metadata and controls
28 lines (24 loc) · 744 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
<!DOCTYPE html>
<html>
<head>
<title>Counter</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
let counter = 0;
document.querySelector('#increase').onclick = () => {
counter++;
document.querySelector('h1').innerHTML = counter;
};
document.querySelector('#decrease').onclick = () => {
counter--;
document.querySelector('h1').innerHTML = counter;
};
});
</script>
</head>
<body>
<h1>0</h1>
<button id="increase">+</button>
<button id="decrease">-</button>
</body>
</html>