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

140
Visualizações
click on img using jquery not working on mobile

i have following code

$('.radio-color').click(function () {
                            $('.radio-color').removeClass('selected');
                            $(this).addClass('selected');
                            var color = $(this).attr('value');
                            //alert('<input type="hidden" name="color" value="'+color+'">');
                            $('#product_color').val(color);
                            $('#h4_color').text('\u00A0' + color);
                            var id = $(this).attr('id');
                            $('.flex-control-thumbs ').find("li:eq("+id+")").find('img').click();
                        });

everything is working fine on PC but the last statement is not working on mobile. which is:

$('.flex-control-thumbs ').find("li:eq("+id+")").find('img').click();

i have tried using touchstart, touchend etc options but none have worked for me so far. i am stuck on it for 3 days now. need immediate help.

thanks in advance

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Maybe try something like this?

var img = $('.flex-control-thumbs ').find("li:eq("+id+")").find('img');
$(img).trigger("click");
about 4 years ago · Santiago Trujillo Relatório

0

Is it IOS you're having trouble with? I've been having trouble registering clicks in IOS myself. Apparently they don't allow that. There's a stack overflow answer somewhere that links to an IBM article explaining that.

One thing you can try doing is remove the ".click()" with something like ".remove()", just to make sure the element is being targeted correctly (maybe some mobile media query is shifting things around?)

Worst case scenario, can you replicate your click function without actually clicking the element?

Another thing you can try: Somewhere in your code, there must be a click function assigned to that element, right? Something like:

$('.the-element').on('click', function(){});

Try replacing that with

$('.the-element').on('click newTrigger', function(){});

Then in your code above, replace

$('.flex-control-thumbs ').find("li:eq("+id+")").find('img').click();

With

$('.flex-control-thumbs ').find("li:eq("+id+")").find('img').trigger('newTrigger');

I also see adding cursor: pointer; in CSS works for some people on the element to be clicked.

about 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