Search code examples
jqueryiphoneclickwindow.opentouchstart

Touchstart click event is not working for iPhone / iPade


I've written an event to open new browser tab (window.open) by jQuery like below:

$(document).on('touchstart click', '.myClass', {self: this}, function (e) {

    var mylink = e.data.self.validateDomValue(this, 'attr=data-affiliate')

    if(myLink)
    {
        window.open(mylink, '_blank');
    }
});

This scripts working well for windows, mac and iPad but the problem is arising for iPhone. The event is not firing for iPhone (version: 5, 6 and 7). What was my mistake? Any of your suggestion will be appreciated.


Solution

  • Oh! Yes! I got the point. I need to use css cursor:pointer. That works for me.

    if (/iP(hone|od|ad)/.test(navigator.platform)) 
    {
        $(".myClass").css({"cursor":"pointer"});
    }