-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (28 loc) · 721 Bytes
/
app.js
File metadata and controls
35 lines (28 loc) · 721 Bytes
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
const counter=document.getElementById('counter');
const btns= document.querySelectorAll('.btn');
//console.log(btns);
let count=0;
btns.forEach((btns)=>{
btns.addEventListener('click',(e)=>{
const styles= e.currentTarget.classList;
if(styles.contains('increase')){
count++;
}
else if(styles.contains('decrease')){
count--;
}
else if(styles.contains("reset")){
count=0;
}
if(count>0){
counter.style.color='green';
}
else if(count<0){
counter.style.color='red';
}
else{
counter.style.color='grey';
}
counter.textContent=count;
})
})