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系统都能满足!

 

posted @ 2018-04-09 17:36  web_study  阅读(1948)  评论(0编辑  收藏  举报

哈哈