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

前端 未结 7 1035
梦毁少年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条回答
  •  梦毁少年i
    2021-02-04 06:28

    These answers got me started on the right direction (first google for "jquery document.on ipad"), so thanks for that, but borrowing from this answer I simplified it to something like this:

    $(document).on("click touchstart", function (ev) {
        ...
    });
    

    This would obviously produce undesired results if a platform (like Android or Windows Phone or something) supported both click and touchstart in the event bubble, so if anyone knows that let me know (and I'll fix my code and delete this answer! :)

提交回复
热议问题