标签:
看某个站的源码实现思路如下:
html:
<div class="family_v2"> <p class="nickname_v2">简介:</p> <textarea id="content" name="sign" style="height:60px;overflow-y: hidden;" onkeyup="changeLength(this,60)" class="nicknameBox_v2 brief_box_v2"> </textarea> <div class="limit_num_v2"> <h3>60</h3> </div> </div>
js:
//验证textarea的长度 function changeLength(obj,lg){ var len = $(obj).val(); $(obj).next().find("h3").text(lg-len.length); if(len.length>=lg){ $(obj).next().find("h3").text(0); $(obj).val(len.substring(0,lg)); } }
标签:
原文地址:http://my.oschina.net/ydsakyclguozi/blog/378625