Book
Submodule 7.3: Word count
Submodule 7.3: Word count
Completion requirements
View
- JavaScript word counter
The HTML file
This is the HTML file:
As you can see, we have given an id to the textarea. Also, we have given an id to an empty span. This is where we will display our wordcount using JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Word counter </title>
</head>
<body>
<h3> Word counter </h3>
<textarea id="myWordsToCount" rows="5" cols="60" ></textarea><br>
The wordcount is: <span id="wordcount"></span><br>
<script type="text/javascript" src="js/countsTheWords.js"></script>
</body>
</html>
Exercise
- Open your editor, create a new file and save it as
exersice07.3.01.html
in the folder "yourNameWEB2JS". - Copy the above code and paste it into the new file.
- Modify and save the file.