は、私は、次のコードを持っていますが、本部IDパラからのテキストが最後の言葉と次の文の最初の単語は1単語の代わりに、2問題
コードとしてそれに参加し、意見ました:
var value = $('#RichHtmlField_displayContent').text();
console.log("text", value)
if (value.length == 0) {
$('#show_word_count').html(0);
return;
}
var wordCount = value.match(/\S+/ig).length
$('#show_word_count').html(wordCount);
};
$(document).ready(function() {
$('#RichHtmlField_displayContent').change(counter);
$('#RichHtmlField_displayContent').keydown(counter);
$('#RichHtmlField_displayContent').keypress(counter);
$('#RichHtmlField_displayContent').keyup(counter);
$('#RichHtmlField_displayContent').blur(counter);
});
だから、私は何をしたい、その後、総単語数をカウントすべてのピリオド、疑問符の後にスペースを追加しています。
コードの書式を整理すると、孤立した括弧が '};'であることがわかります。また、実用的なサンプル/スニペットを提供した場合は、非常に便利です。 – Moob