-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpractical-15.html
66 lines (64 loc) · 1.59 KB
/
practical-15.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practical-15</title>
<style>
body {
background-color: grey;
}
h1 {
color: white;
text-align: center;
}
div {
display: flex;
justify-content: center;
}
p {
padding: 10px 15px;
border: 2px solid grey;
color: grey;
background-color: yellow;
width: 20px;
text-align: center;
font-size: 30px;
cursor: pointer;
}
div #decrease {
margin-right: 40px;
}
div #increase {
margin-left: 40px;
}
p:hover {
color: black;
border: 2px solid black;
}
div #num {
background-color: grey;
color: yellow;
border: none;
}
</style>
</head>
<body>
<h1>COUNTER</h1>
<div>
<p id="decrease" onclick="decrement()">-</p>
<p id="num">0</p>
<p id="increase" onclick="increment()">+</p>
</div>
<script>
function decrement() {
var num = parseInt(document.getElementById("num").innerHTML);
document.getElementById("num").innerHTML = num - 1;
}
function increment() {
var num = parseInt(document.getElementById("num").innerHTML);
document.getElementById("num").innerHTML = num + 1;
}
</script>
</body>
</html>