Advertisements
<!DOCTYPE html> <html> <head> <title>Word Counter</title> </head> <body> <h1>Word Counter</h1> <textarea id="textInput"></textarea><br> <button id="countBtn">Count Words</button><br><br> <p>Number of Words: <span id="wordCount"></span></p> <script> const countBtn = document.querySelector("#countBtn"); const textInput = document.querySelector("#textInput"); const wordCount = document.querySelector("#wordCount"); countBtn.addEventListener("click", function() { const words = textInput.value.trim().split(/\s+/); wordCount.textContent = words.length; }); </script> </body> </html>
how to create word counter big text area web pgae using html
To create a word counter web page with a large text area using HTML, you can use the following code:
<!DOCTYPE html><html><head><title>Word Counter</title><style>textarea {width: 500px;height: 300px;}</style></head><body><h1>Word Counter</h1><textarea id="textInput"></textarea><br><button id="countBtn">Count Words</button><br><br><p>Number of Words: <span id="wordCount"></span></p><script>const countBtn = document.querySelector("#countBtn");const textInput = document.querySelector("#textInput");const wordCount = document.querySelector("#wordCount");countBtn.addEventListener("click", function() {const words = textInput.value.trim().split(/\s+/);wordCount.textContent = words.length;});</script></body></html>
Advertisements
0 Comments