基于jQuery的140字输入限制
一个基于jQuery的文字输入限制。
html:
<p>还可以输入 <span id="remLen"></span> 个字</p> <textarea name="content" id="status" class="textarea">#今日最给力话题#</textarea>
javascript:
<script type="text/javascript"> $(function(){ var max_len = 140; $("#remLen").text(max_len - $("#status").val().length); $("#status").bind('change ' + ($.browser.msie ? "propertychange" : "input"), function(event){ var val = $.trim($(this).val()), len = val.length; if(len > max_len) { $(this).val(val.substr(0, max_len)); } else { $("#remLen").text(max_len - len); } }); }) </script>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17