私が書いた量を示すテキスト領域が必要で、値の最大長のうち、テキスト領域の右下 (テキストボックス内) に表示されます。その方法が見つかりません。ありがとう。
2339 次
2 に答える
-1
使える機能はこちら
ジャバスクリプト:
function CountWords(s) {
var maxChars = 2048;
if (s.value.length > maxChars) {
s.value = s.value.substring(0, maxChars);
}
else {
$($(s).parent()).find("#words").html((maxChars - s.value.length) + " characters left.");
}
}
HTML:
<textarea onkeyup="CountWords(this)" id="txtBody" rows="50" cols="10"
></textarea>
<span id="words" style="width: 120px; color:Gray; display: block; float: left; margin: 5px; line-height: 27px;">
2048 characters left.</span>
数字を、必要な文字制限の数に変更するだけです。
于 2013-07-18T10:24:35.547 に答える