IOS系统兼容input keyup事件

Posted web_study

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IOS系统兼容input keyup事件相关的知识,希望对你有一定的参考价值。

最近在做移动端模糊搜索功能,js监听input的keyup事件,在chrom模拟器和android手机环境运行都没有问题,到了ios手机却出现bug,没法实现功能;

查了好一会资料,发现keyup事件在ios系统下存在不兼容问题,解决的方法是通过 html5的 oninput事件来实现,代码如下;

<input id="input" type="text" />
document.querySelector(‘#input‘).addEventListener(‘input‘,function(){
    //do something
});
            document.querySelector(‘#input‘).oninput=function(){
    //do something
}    

上面两种写法都可以,android和ios系统都能满足!

 

以上是关于IOS系统兼容input keyup事件的主要内容,如果未能解决你的问题,请参考以下文章