你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

input在ios系统无法识别keyup写法的字数改动

2021/12/28 14:44:20

将keyup写法改为input propertychange

模板:

$(".input").bind('input propertychange', function() {undefined
})

一个计算input输入框字数计算的方法(ios适配)

//多行文本框字符计算
//     $('#textArea').bind('input propertychange', function() {
    $('#textArea').bind('input propertychange', function() {
        $('#textNum').text($('#textArea').val().length);//这句是在键盘按下时,实时的显示字数
        if($('#textArea').val().length > 100){
            $('#textNum').text(100);//长度大于100时0处显示的也只是100
            $('#textArea').val($('#textArea').val().substring(0,100));//长度大于100时截取钱100个字符
        }
    })
    $('#textNum').text($('#textArea').val().length);//这句是在刷新的时候仍然显示字数