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

前端 未结 7 1027
梦毁少年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:32

    I have used this:

    jQuery(document).on('touchstart',function(event){
        //your code here
             });
    

    -also instead of "document" you can bind to any DOM object.

    and this(from another forum answer):

    var body = document.getElementsByTagName('body')[0];
    
     if ("ontouchstart" in window) {
    
            body.ontouchstart = function(){
       //your code here
             };     
                     };
    

    -again, you don't have to use 'body' you can assign a variable to an object by class this way:

    var dd = document.getElementsByClassName('infoAction')[0]; 
    

提交回复
热议问题