Function Focus Jquery not working mobile

Asked

Viewed 74 times

0

I have the following function in my code .js:

element = $('.bloco-pesquisa').find('#inp-pesquisa');

element.focus(function(){
    alert("focus!");
    if (!load_autocomplete){
        $.getScript('/js/jquery.typing-0.2.0.min.js');
        $.getScript('/js/autocomplete.js');
        load_autocomplete = true;
    }
});

In the browsers on the computer works, already on Chrome or other browser on tablet/mobile.

Someone knows where I’m going wrong or some way to make it work?

I’ve tried to use:

.on('click touchstart', function () {

.on('click touch', function () {

.on('click touchend', function () {

None of those options worked.

  • the events click touch* has a different function than focus, but if they didn’t work, it’s very likely that some javascript script (either jQuery or not) is in conflict in the browser and is causing an error, causing the rest of the JS to stop. Test on IE 9 (usually has similar compatibility and causes the same errors) and test on mobile by firing the event .focus manually: document.getElementById("textBox").focus();

  • Hmm. Thank you, I’ll look for any errors prior to that code.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.