File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Modifies by Aachman
2+ let count = 0 ;
3+ const value = document . querySelector ( "#value" ) ;
4+ const btns = document . querySelectorAll ( ".btn" ) ;
5+
6+ btns . forEach ( function ( btn ) {
7+ btn . addEventListener ( "click" , function ( e ) {
8+ const styles = e . currentTarget . classList ;
9+ if ( styles . contains ( "decrease" ) ) {
10+ count -- ;
11+ } else if ( styles . contains ( "increase" ) ) {
12+ count ++ ;
13+ } else {
14+ count = 0 ;
15+ }
16+
17+ if ( count > 0 ) {
18+ value . style . color = "green" ;
19+ }
20+ if ( count < 0 ) {
21+ value . style . color = "red" ;
22+ }
23+ if ( count === 0 ) {
24+ value . style . color = "#222" ;
25+ }
26+ value . textContent = count ;
27+ } ) ;
28+ } ) ;
Original file line number Diff line number Diff line change 33 < head >
44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6- < title > Counter</ title >
6+ < title > Counter by Aachman </ title >
77
88 <!-- styles -->
99 < link rel ="stylesheet " href ="styles.css " />
You can’t perform that action at this time.
0 commit comments