Answers for "Reading Time with jquery"

1

Reading Time with jquery

$(function () {
    var txt = $(".content").text();
    
    wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length;

    var readingTimeInMinutes = Math.floor(wordCount / 228) + 1;
    var readingTimeAsString = readingTimeInMinutes + " min";
    
    $('article .reading-time').html(readingTimeAsString);
});
Posted by: Guest on October-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language