<div class="srk">
<input type="text" placeholder='请输入问题' id="wby0" data-max='100' maxLength='100' onkeyup="wby(0)" />
<div class="tishiNum"><span id='titleNum'>0</span>/100</div>
</div>
<script type="text/javascript">
function wby(e){
var length = $('#wby'+e).val().length;
if(length>$('#wby'+e).data('max')){
alert('字数请在100字以内')
}else{
$('#wby'+e).closest('.srk').find('#titleNum').text(length)
}
}
</script>
输入框限制字数数量
最新推荐文章于 2023-07-19 14:21:48 发布