解决办法:
#descrip 是textarea的id,字数小于40;
$("#descrip").on(‘input‘,function(event) {
if ($("#descrip").val().length >= 40) {
$("#descrip").val($("#descrip").val().substring(0,40));
}
原文:http://www.cnblogs.com/shenyangxiaohuo/p/5236711.html