Jquery keyup not working on Android

后端 未结 2 2060
情书的邮戳
情书的邮戳 2020-12-18 00:23

i didn\'t tested this code on iPhone but i\'m sure (tested) it doesn\'t works on android mobiles:

 $(\'#search\').live(\'keyup\',function(key){
          if(         


        
相关标签:
2条回答
  • 2020-12-18 00:55
    $(document).on('keyup','#search', function() {
       // code
    });
    

    or

    $(document).delegate('#search', 'keyup', function() {
        // code
    });
    

    You can also see here

    0 讨论(0)
  • 2020-12-18 01:12

    My solution (working with jQuery 1.7.1):

    $('#search').live('input paste', yourFunction)
    

    Tip:

    Use .on() instead of .live(), because:

    • .on() is faster
    • .live() is deprecated

    jQuery 1.7+ .on() vs .live() Review

    Try this:

    $(document).on('input paste', '#search', yourFunction)
    
    0 讨论(0)
提交回复
热议问题