File tree Expand file tree Collapse file tree
task08-live-character-counter 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 > Live Character Counter</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ </ head >
9+ < body >
10+ < div class ="container ">
11+ < input type ="text " id ="inputBox " placeholder ="Enter your text... ">
12+ < p id ="counter "> Characters: 0</ p >
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 input = document . getElementById ( "inputBox" ) ;
2+ const counter = document . getElementById ( "counter" ) ;
3+
4+ input . addEventListener ( "input" , ( ) => {
5+ const length = input . value . length ;
6+ counter . textContent = `Characters: ${ length } ` ;
7+ } ) ;
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, # 485678, # 098765 );
5+ }
6+
7+ .container {
8+ background-color : white;
9+ padding : 50px 80px ;
10+ border : none;
11+ border-radius : 50px ;
12+ width : 20% ;
13+ margin : auto;
14+ }
15+
16+ input {
17+ width : 90% ;
18+ padding : 10px ;
19+ font-size : 15px ;
20+ border : 3px solid grey;
21+ border-radius : 8px ;
22+ }
23+
24+ p {
25+ margin-top : 20px ;
26+ margin-bottom : -20px ;
27+ }
You can’t perform that action at this time.
0 commit comments