<textarea name="" id="FashionStatement" cols="30" rows="10"></textarea> <div id="statementRowChk"></div>
$(‘#FashionStatement‘).val(‘‘); var limitNum = 40; var pattern = ‘还可以输入‘ + limitNum + ‘字‘; $(‘#statementRowChk‘).html(pattern); $(‘#FashionStatement‘).keyup( function() { var remain = $(this).val().length; if (remain > 40) { pattern = ‘字数超过限制,请适当删除部分内容‘; } else { var result = limitNum - remain; pattern = ‘还可以输入‘ + result + ‘字‘; } $(‘#statementRowChk‘).html(pattern); } );
时间: 2024-12-12 08:22:32