-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (70 loc) · 1.67 KB
/
index.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
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
96
97
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<style>
body{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.box{
height: 200px;
width: 320px;
text-align: center;
padding: 10px;
background-color: rgb(239, 239, 240);
box-shadow: 0px 0px 5px rgb(149, 168, 253);
}
h1{
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
button{
height: 35px;
width: 100px;
background-color: transparent;
border: none;
box-shadow: 0px 0px 2px blue;
}
button:hover{
background-color: rgb(131, 131, 255);
color: white;
transition: 0.6s;
}
</style>
<div class="box">
<h1>Counter</h1>
<h1 id="text">0</h1>
<button id="plus">Inc++</button>
<button id="minus">Dec++</button>
<button id="reset">Reset</button>
</div>
<script>
let plus = document.getElementById('plus');
let minus = document.getElementById('minus');
let reset = document.getElementById('reset');
let text = document.getElementById('text');
let Number = 0 ;
plus.addEventListener('click' , function(){
Number++
text.innerText = Number ;
});
minus.addEventListener('click' , function(){
Number--
if( Number < 0 ){
Number = 0 ;
}
text.innerText = Number ;
});
reset.addEventListener('click' , function(){
Number = 0 ;
text.innerText = Number ;
});
</script>
</body>
</html>