- <div id="commentBox">
- <textarea name="" cols="30" rows="3" placeholder="请输入你的内容……"></textarea>
- <div>还能输入<span>140</span> 字</div>
- </div>
- function maxLimit(){
- var num=$(this).val().substr(0,140);
- var $num2=$(this).val().length;
- var $tnum=140-$num2;
- $(this).val(num);
- $(this).next().children("span").text($tnum);
- };
- $("#commentBox textarea").keyup(maxLimit);