-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes_for_button
92 lines (78 loc) · 2.08 KB
/
notes_for_button
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
<!-- the html content -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>KEEP THE COUNT</h1>
<h2 id="count-el">0</h2>
<button id="increment-btn" onclick="increment()">PLUS THE COUNT</button> <br>
<button id="decrement-btn" onclick="decrement()">MINUS COUNT</button><br>
<button id="save-btn" onclick="save()">SAVE</button><br>
<p id="save-el" >Previous records :-</p>
</body>
<script src="index.js"></script>
</html>
<!-- the html content -->
<!-- THE CSS CONTENT -->
body {
background-image: url("station.jpg");
background-size: cover;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: bold;
text-align: center;
}
h1 {
margin-top: 10px;
margin-bottom: 10px;
font-style: italic;
}
h2 {
font-size: 50px;
margin-top: 0;
margin-bottom: 20px;
}
button {
border: none;
padding-top: 10px;
padding-bottom: 10px;
color: white;
font-weight: bold;
width: 200px;
margin-bottom: 5px;
border-radius: 5px;
}
#increment-btn {
background: rgb(37, 22, 197);
}
#decrement-btn {
background-color: rgb(227, 19, 57);
}
#save-btn {
background: rgb(34, 161, 34);
}
<!-- THE CSS CONTENT -->
<!-- THE JS CONTENT -->
let countEl = document.getElementById("count-el");
let saveEL = document.getElementById("save-el");
console.log(countEl);
let count = 0
function increment(){
count = count + 1;
countEl.innerText = count;
}
function decrement(){
count = count - 1
countEl.innerText = count;
}
function save() {
let countstr = count + " - "
<!-- instead of innerText we can use textContent because innerText only display human readable language -->
saveEL.innerText += countstr;
console.log(count)
}
<!-- THE JS CONTENT -->