转自:https://www.cnblogs.com/shinepolo/articles/1373113.html
1
<script type="text/javascript"> 2 3 function show(a,b) { 4 var maxl = 400 5 var s = document.getElementById(a).value.length + 1; 6 if (s > maxl) 7 document.getElementById(a).value = document.getElementById(a).value 8 .substr(0, maxl - 1) 9 else 10 document.getElementById(b).innerHTML = "已输入:" + s + "/" + maxl 11 + " 字符" 12 } 13 </script> 14 15 16 <s:textarea onkeydown="show();" id="a"></s:textarea> 17 <div><span id ="b">已输入字符:</span></div>

 

posted on 2016-07-01 11:34  Sharpest  阅读(384)  评论(0编辑  收藏  举报