JavaScript中统计Textarea字数并提示还能输入的字符

<span style="font-size:18px;"><script language="javascript">
function countChar(textareaName,spanName)
{
document.getElementById(spanName).innerHTML = 140 - document.getElementById(textareaName).value.length;
}
</script>
可以输入<span id="counter">140</span>字<br/>
<textarea id="status" name="status" rows="6" cols="40" onkeydown='countChar("status","counter");'
onkeyup='countChar("status","counter");'></textarea></span>

 

http://www.jb51.net/article/50887.htm

posted @ 2015-11-20 17:21  seasonzone  阅读(395)  评论(0编辑  收藏  举报