-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter2.html
More file actions
28 lines (23 loc) · 662 Bytes
/
counter2.html
File metadata and controls
28 lines (23 loc) · 662 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>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelector('button').onclick = count;
});
let counter = 0;
function count() {
counter++;
document.querySelector('#counter').innerHTML = counter;
if (counter % 10 === 0) {
alert(`Counter is at ${counter}!`);
}
}
</script>
<title>My Website</title>
</head>
<body>
<h1 id="counter">0</h1>
<button>Click Here!</button>
</body>
</html>