textarea支持复制粘贴的文本计数器

     function statInputNum( textArea, numItem ) {
 var max = textArea.attr( "maxlength");
 var curLength=0;
 curLength = textArea.val()
   .length;
 
 numItem.text(max-curLength);
 textArea.on( 'input propertychange', function () {
   var _value = $( this )
     .val()
     .replace( /\n/gi, "" );
    numItem.text( max - _value.length );
 } );
}
text1.on('focus',function(){
statInputNum(text1,len1)

  })


 

50/50

你可能感兴趣的:(JavaScript,Jquery)