解决办法:
#descrip 是textarea的id,字数小于40;
$("#descrip").on('input',function(event) {
if ($("#descrip").val().length >= 40) {
$("#descrip").val($("#descrip").val().substring(0,40));
}
}
本文介绍了如何使用 jQuery 对 textarea 的输入进行限制,确保文本长度不超过40个字符。通过监听 input 事件并使用 substring 方法,可以实现这一功能。
解决办法:
#descrip 是textarea的id,字数小于40;
$("#descrip").on('input',function(event) {
if ($("#descrip").val().length >= 40) {
$("#descrip").val($("#descrip").val().substring(0,40));
}
}
转载于:https://www.cnblogs.com/shenyangxiaohuo/p/5236711.html

被折叠的 条评论
为什么被折叠?