-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathass9.html
More file actions
95 lines (79 loc) · 1.93 KB
/
ass9.html
File metadata and controls
95 lines (79 loc) · 1.93 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
<title>Interactive Counter</title>
<style>
body {
font-family: 'Times New Roman', Times, serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background: #f0f8ff;
}
h1 {
margin-bottom: 30px;
}
.counter {
font-size: 48px;
margin: 20px 0;
padding: 10px 30px;
border: 2px solid #9dd8ff;
border-radius: 8px;
color: #9dd8ff;
background-color: #ffffff;
}
.buttons {
display: flex;
gap: 20px;
}
button {
padding: 10px 20px;
font-size: 18px;
border: none;
border-radius: 5px;
background-color: #9dd8ff;
color: white;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #9dd8ff;
}
button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
</style>
</head>
<body>
<h1>Interactive Counter</h1>
<div class="counter" id="counter">0</div>
<div class="buttons">
<button onclick="decrement()" id="decrementBtn">Decrement</button>
<button onclick="increment()">Increment</button>
</div>
<script>
let count = 0;
const counterDisplay = document.getElementById("counter");
const decrementBtn = document.getElementById("decrementBtn");
function updateDisplay() {
counterDisplay.textContent = count;
decrementBtn.disabled = count === 0;
}
function increment() {
count++;
updateDisplay();
}
function decrement() {
if (count > 0) {
count--;
updateDisplay();
}
}
updateDisplay();
</script>
</body>
</html>