📜  使用 jquery 阅读时间 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:14.731000             🧑  作者: Mango

代码示例1
$(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);
});