text box limit

 
 
//Similar to QQ to talk about limiting the number of characters entered in the text box, the KEYUP event is triggered
// Limit the number of characters entered in the text box
 $( "#saythings" ). keyup ( function (){
     var len = $( this ). val (). length ;
 if (len > 2000 ){$( this ). val ( $( this ). val (). substring ( 0 , 2000 )) ; }
     var num = 2000 - len ;
 $( ".counter" ). text (num) ;
 }) ;        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325508705&siteId=291194637