0
從textarea獲取文本統計信息。從textarea獲取統計信息
哪個更好?
這一個?
function getStats() {
var text = textarea.value,
stats = {};
stats.chars = text.length;
stats.words = text.split(/\S+/g).length - 1;
stats.lines = text.replace(/[^\n]/g, "").length + 1;
return stats.lines + " lines, " + stats.words + " words, " + stats.chars + " chars";
}
還是這個?
它沒有在所有問題在這種情況下, –