Catching the Click on DOM/HTML/BODY event on the iPad

前端 未结 7 1029
梦毁少年i
梦毁少年i 2021-02-04 05:55

I\'m using jQuery to detect a click on the DOM - or let\'s every click.

$(document).click(function(){
   alert(\"Click :-)\");
});

This works p

相关标签:
7条回答
  • 2021-02-04 06:44

    As I found on http://www.danwellman.co.uk/fixing-jquery-click-events-for-the-ipad/ you may test the user agent and use touchstart or click depending on the platform

    var ua = navigator.userAgent,
            event = (ua.match(/iPad/i)) ? "touchstart" : "click";
    
    $(document).on(event, function (ev) {
        ...
    });
    
    0 讨论(0)
提交回复
热议问题