Words Count

Counts numbers of words in entered text. Assumes words are separated by space

by Uzair Mehmood

HTML

<label for="input">Count words in :</label>
<input type="text" id="input" />
<hr>
<p id="output"></p>

JavaScript

$("#input").change(function () {
    
    var words = $(this).val().split(" ");
    var wordsCount = words.length;
    $("#output").text("Total amount of words seperated by space in entered text : " + wordsCount);

});