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
Maybe try something like this?
var img = $('.flex-control-thumbs ').find("li:eq("+id+")").find('img');
$(img).trigger("click");
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.