File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ <h1>Word and Letter counter</h1>
3737 < textarea name ="counter " id ="text-area " rows ="10 " placeholder ="Enter text here "> </ textarea >
3838 < div class ="count ">
3939 < h5 > Word : < span id ="word-count "> 0</ span > </ h5 >
40+ < button id ="clear "> Clear</ button >
4041 < h5 > Letter: < span id ="letter-count "> 0</ span > </ h5 >
4142 </ div >
4243 </ div >
Original file line number Diff line number Diff line change 11const textarea = document . getElementById ( "text-area" ) ;
22const wordcount = document . getElementById ( "word-count" ) ;
33const lettercount = document . getElementById ( "letter-count" ) ;
4+ const clear = document . getElementById ( "clear" ) ;
45
56textarea . addEventListener ( "keyup" , ( ) => {
67 count ( ) ;
@@ -18,3 +19,9 @@ const count = () => {
1819
1920 wordcount . innerText = filtered . length ;
2021} ;
22+
23+ clear . addEventListener ( "click" , ( ) => {
24+ textarea . value = "" ;
25+ wordcount . innerText = 0 ;
26+ lettercount . innerText = 0 ;
27+ } )
Original file line number Diff line number Diff line change 4545.count {
4646 display : flex;
4747 justify-content : space-around;
48+ align-items : center;
4849 font-size : 1.2rem ;
4950}
5051
5152span {
5253 color : white;
54+ padding : 10px ;
55+
56+
5357}
5458
5559h5 {
5660 color : blueviolet;
5761
62+ }
63+
64+ button {
65+ background-color : red;
66+ border : none;
67+ border-radius : 10px ;
68+ font-size : 1.2rem ;
69+ padding : 10px ;
70+ color : white;
71+ cursor : pointer;
72+ }
73+
74+ button : hover {
75+ background-color : green;
5876}
You can’t perform that action at this time.
0 commit comments