File tree Expand file tree Collapse file tree
task09-increase-counter-on-every-button-click Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Click Counter Button</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < h1 id ="heading "> Counter: 0</ h1 >
12+ < button id ="button "> Click here to Increase the Counter</ button >
13+ </ div >
14+
15+ < script src ="script.js "> </ script >
16+ </ body >
17+ </ html >
Original file line number Diff line number Diff line change 1+ const heading = document . getElementById ( "heading" ) ;
2+ const button = document . getElementById ( "button" ) ;
3+
4+ let count = 0 ;
5+
6+ button . addEventListener ( "click" , ( ) => {
7+ count ++ ;
8+ heading . textContent = `Counter: ${ count } ` ;
9+ } )
Original file line number Diff line number Diff line change 1+ body {
2+ padding : 200px ;
3+ text-align : center;
4+ background : linear-gradient (to right, # 654754, # 647284 );
5+ }
6+
7+ .container {
8+ background-color : white;
9+ border : none;
10+ border-radius : 50px ;
11+ width : 25% ;
12+ margin : auto;
13+ padding : 30px 80px 50px 80px ;
14+ }
15+
16+ button {
17+ font-size : 15px ;
18+ padding : 10px 20px ;
19+ border : none;
20+ border-radius : 10px ;
21+ color : white;
22+ background-color : cornflowerblue;
23+ font-weight : 600 ;
24+ cursor : pointer;
25+ }
26+
27+ button : hover {
28+ background-color : rgb (45 , 102 , 207 );
29+ }
You can’t perform that action at this time.
0 commit comments