Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
How to bind a click event in iOS?

I'm "just" trying to bind a click event to a <button> and make it work for Desktop (chrome, FF, ... ), android and iOS.

I tried a lot of stuff such as this cursor: pointer which seemed to be the easiest and most effective but didn't work.

I also tried an onclick='' or onclick='void(0)' on the HTML element, a trick I've seen I don't even remember where ...

I tried with extern libraries such as FastClick to delete to 300ms wait after a click ... Doesn't work

And no more chance with Pointer Events Polyfill and binding with pointerup ...

I've run out of ideas ...

My HTML :

<div class="col-md-12">
    <button type="button" onclick='' id="begin" class="btn andro btn-danger btnlg">
        <img src="img/icon.png" height="50px"> GO
        <img src="img/icon.png" height="50px">
    </button>
</div>

My JS :

  $(document).on('touchstart', '#begin', function() {
      // do things
  });

I tried of course to bind touchstart (even touchend !) instead of click and still doesn't work on iphones ...

The problem is : I don't have an iphone to test my stuff so I have to trust some friends who have an iOS device ... Do I have to change my code ... Or change my friends ? ^^

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Soooo.... After a lot of searches and tries such as removing one by one libraries and commenting parts of the code...

I was able to find what was messing with the click ... It was because my bindings were encapsulated in a :

$( document ).ready(function() {
    // My bindings here
});

and it seems like iOS don't like this ...

Just bind your click out of the ready function and it works... Hope it can help someone !

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda