-
Notifications
You must be signed in to change notification settings - Fork 0
/
onClick.html
33 lines (33 loc) · 1.14 KB
/
onClick.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
<!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">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
body {
padding: 25px;
}
</style>
<title>Document</title>
</head>
<body>
<h3><span id="count">0</span>
Likes</h3>
<div>
<button class="btn btn-outline-success" type="button"id="add">👍</button>
<button class="btn btn-outline-danger" type="button"id="sub">👎</button>
</div>
<script>
document.getElementById("add").onclick = () => {
let counter = document.getElementById("count");
counter.innerHTML = Number(counter.innerHTML) + 1;
};
document.getElementById("sub").onclick = () => {
let counter = document.getElementById("count");
counter.innerHTML = Number(counter.innerHTML) - 1;
};
</script>
</body>
</html>