Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery keyup not working on Android

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(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?

like image 724
itsme Avatar asked May 14 '12 09:05

itsme


2 Answers

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

or

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

You can also see here

like image 143
The System Restart Avatar answered Nov 14 '22 10:11

The System Restart


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)
like image 25
user1051870 Avatar answered Nov 14 '22 11:11

user1051870