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> 

 

posted @ 2017-06-10 10:48  林育松  阅读(505)  评论(0编辑  收藏  举报