-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (37 loc) · 982 Bytes
/
script.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
37
38
39
40
41
42
//const add = document.querySelector(".add");
//const resetCount = document.querySelector(".reset");
//const sub = document.querySelector(".subtract");
const count = document.querySelector(".count");
const buttons = document.querySelector(".buttons");
buttons.addEventListener("click",(e) =>{
if (e.target.classList.contains("add")) {
count.innerHTML++;
setColor()
}
if (e.target.classList.contains("subtract")) {
count.innerHTML--;
setColor()
}
if (e.target.classList.contains("reset")) {
count.innerHTML=0;
setColor()
}
});
function setColor() {
if (count.innerHTML > 0) {
count.style.color="yellow";
} else if (count.innerHTML < 0){
count.style.color="orange";
}else{
count.style.color="white";
}
}
//add.addEventListener("click",() =>{
// count.innerHTML++;
//});
//sub.addEventListener("click",() =>{
// count.innerHTML--;
//});
//resetCount.addEventListener("click",() =>{
// count.innerHTML=0;
//});