-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
30 lines (28 loc) · 1.02 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<!-- <p class="changeNumber">0</p> -->
<h1 id="number" class="changeNumber">0</h1>
<button id="increament">+</button>
<button id="decrement">-</button>
<script>
const numberEleDiv = document.querySelector("#number");
// const numberEleDiv = document.querySelectorAll(".changeNumber");
// console.log(numberEleDiv);
const changeNum = (event) => {
if (event.target.id === "increament")
numberEleDiv.textContent = parseInt(numberEleDiv.textContent) + 1;
if (event.target.id === "decrement")
numberEleDiv.textContent = parseInt(numberEleDiv.textContent) - 1;
};
increament.addEventListener("click", changeNum);
decrement.addEventListener("click", changeNum);
</script>
</body>
</html>