Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!