-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (33 loc) · 1.06 KB
/
script.js
File metadata and controls
48 lines (33 loc) · 1.06 KB
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
43
44
45
46
47
//const subtract = document.querySelector(".subtract");
//const reset = document.querySelector(".reset");
//const add = document.querySelector(".add");
const count = document.querySelector(".count");
const buttons = document.querySelector(".buttons")
buttons.addEventListener('click', event => {
if(event.target.classList.contains('add'))
count.innerHTML++;
setColor();
if(event.target.classList.contains('subtract'))
count.innerHTML--;
setColor();
if(event.target.classList.contains('reset'))
count.innerHTML = 0;
setColor();
});
const setColor = () => {
if(count.innerHTML > 0) count.style.color = "#16C79A";
else if (count.innerHTML < 0) count.style.color = "#F58634"
else count.style.color = "#fff"
}
/* else if(count.innerHTML < 0) count.style.color("tomato")
else count.style.color = (#fff) */
/* add.addEventListener('click', () => {
count.innerHTML++;
})
subtract.addEventListener('click', () => {
count.innerHTML--;
})
reset.addEventListener('click', () => {
count.innerHTML = 0;
})
*/