请按下回车键
后帮我改变这个计数器功能继续计数function countWords(text) {
var normalizedText = text.
replace(/(\r\n|\n|\r)/gm, " ").
replace(/^\s+|\s+$/g, "").
replace(" ", " ");
normalizedText = strip(normalizedText);
var words = normalizedText.split(/\s+/);
for (var wordIndex = words.length - 1; wordIndex >= 0; wordIndex--) {
if (words[wordIndex].match(/^([\s\t\r\n]*)$/)) {
words.splice(wordIndex, 1);
}
}
return (words.length);
}
答案 0 :(得分:1)
如果页面提交,请将字段包装在<form></form>
并且
document.querySelector("form").onsubmit=function() { return false }
之后的脚本中的