javascript Jquery keyup 不适用于 Android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10580295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery keyup not working on Android
提问by itsme
i didn't tested this code on iPhone but i'm sure (tested) it doesn't works on android mobiles:
我没有在 iPhone 上测试过这段代码,但我确定(测试过)它在安卓手机上不起作用:
$('#search').live('keyup',function(key){
if(key.which == 13){
/*ANIMATE SEARCH*/
_key = $(this).val();
$("#wrapper").html("");
$('#wrapper').hide(0).load('results.html').fadeIn(800);
$('#search-fade').val(_key).fadeIn();
}
});
to explain better :
更好地解释:
i have a simple
我有一个简单的
<input type="text" name="search" id="search"/>
don't know why but this code doesn't works properly on android mobile phones
不知道为什么,但这段代码在安卓手机上不能正常工作
any ideas?
有任何想法吗?
回答by The System Restart
回答by user1051870
My solution (working with jQuery 1.7.1):
我的解决方案(使用 jQuery 1.7.1):
$('#search').live('input paste', yourFunction)
Tip:
小费:
Use .on()
instead of .live()
, because:
使用.on()
代替.live()
,因为:
.on()
is faster.live()
is deprecated
.on()
是比较快的.live()
已弃用
jQuery 1.7+ .on() vs .live() Review
jQuery 1.7+ .on() vs .live() 回顾
Try this:
试试这个:
$(document).on('input paste', '#search', yourFunction)