Skip to content

Commit 0740123

Browse files
committed
clear button added
1 parent 7fe1a7f commit 0740123

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

word-counter/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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>

word-counter/script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const textarea = document.getElementById("text-area");
22
const wordcount = document.getElementById("word-count");
33
const lettercount = document.getElementById("letter-count");
4+
const clear = document.getElementById("clear");
45

56
textarea.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+
})

word-counter/styles.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,32 @@ h1 {
4545
.count {
4646
display: flex;
4747
justify-content: space-around;
48+
align-items: center;
4849
font-size: 1.2rem;
4950
}
5051

5152
span {
5253
color: white;
54+
padding: 10px;
55+
56+
5357
}
5458

5559
h5 {
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
}

0 commit comments

Comments
 (0)