-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
36 lines (36 loc) · 1.21 KB
/
main.js
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
document.title = "project-js-9";
document.body.style.cssText = `
height: 100vh;
margin: 0;
padding: 0;
font-family: sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
-webkit-tap-highlight-color: transparent;
-moz-tap-highlight-color: transparent;
user-select: none;
`;
let Likes = document.getElementById("Likes");
let add = document.getElementById("+");
let remove = document.getElementById("-");
let num = window.localStorage.getItem("number");
window.onload = function (params) {
if (window.localStorage.getItem("number") !== null) {
Likes.innerHTML = `${window.localStorage.getItem("number")}`;
console.log("localStorage Not Empty")
}
}
add.onclick = function (params) {
window.localStorage.setItem("number", ++num)
if (window.localStorage.getItem("number") !== null) {
Likes.innerHTML = window.localStorage.getItem("number");
}
}
remove.onclick = function (params) {
window.localStorage.setItem("number", --num)
if (window.localStorage.getItem("number") !== null) {
Likes.innerHTML = window.localStorage.getItem("number");
}
}