textarea支援複製貼上的文字計數器
阿新 • • 發佈:2019-02-13
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)
})
<textarea type="text" style="border:1px solid #d5d3d3;" class="input" id="operatingIncome" maxlength="50" placeholder="請輸入其他經營收入"></textarea>
<div class="tooltip"><span id="operatingIncomeNumber">50</span>/50</div>