-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
39 lines (39 loc) · 1.15 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
<!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>
<div style="text-align:center">
<h1>count</h1>
<h2>0</h2>
<button class="plus">+1</button>
<button class="nice">-1</button>
<button class="reset">reset</button>
</div>
</body>
<script>
function plus_cliked(){
cnt = document.querySelector("h2").innerText
cnt=parseInt(cnt)
cnt+=1
document.querySelector("h2").innerText=cnt
}
document.querySelector(".plus").addEventListener("click",plus_cliked)
function nice_clicked(){
cnt = document.querySelector("h2").innerText
cnt = parseInt(cnt)
cnt-=1
document.querySelector("h2").innerText=cnt
}
document.querySelector(".nice").addEventListener("click",nice_clicked)
function reset_clicked(){
cnt = document.querySelector("h2").innerText
cnt = 0
document.querySelector("h2").innerText=cnt
}
document.querySelector(".reset").addEventListener("click",reset_clicked)
</script>
</html>