Javascript 在iPhone上单击并滚动

Javascript 在iPhone上单击并滚动,javascript,jquery,ios,Javascript,Jquery,Ios,我正试图关闭一个侧菜单onclick。但是,touchstart也会将滚动检测为单击,touchsend也是如此。 如何检测iPhone上的点击(而不是滚动) $('#html').on("click touchstart",function(e) { var optionsmenue = $(".adminmenu_label"); if(!optionsmenue.is(e.target) && optionsmenue.has(e.target)

我正试图关闭一个侧菜单
onclick
。但是,
touchstart
也会将滚动检测为单击,
touchsend
也是如此。 如何检测iPhone上的点击(而不是滚动)

  $('#html').on("click touchstart",function(e) {
      var optionsmenue = $(".adminmenu_label");
      if(!optionsmenue.is(e.target) && optionsmenue.has(e.target).length === 0) {
        document.getElementById("Optionsmenu").style.width = "0%";
        document.getElementById("Optionsmenu").style.transition = "0.2s ease-out";
        document.getElementById("adblue").style.display = "block";
        document.getElementById("whatever").style.display = "block";  
        document.getElementById("not_related").style.display = "block";
        document.getElementById("still_not_related").style.display = "block"; 
        document.getElementById("still_still_not_related").style.width = "100%"; 
      }
    });
应删除中的“touchstart”

应删除中的“touchstart”


检测iOS并添加
光标:指针
对我有效,iOS似乎在事件委派方面有问题

var iOS = ["iPad","iPhone","iPod"].indexOf(navigator.userAgent) > -1;

if(iOS) {
   $('body').css({ cursor : 'pointer' });
}

$('#html').on("click",function(e) {
    // No need for touch start click will do the trick;
});

检测iOS并添加
光标:指针
对我有效,iOS似乎在事件委派方面有问题

var iOS = ["iPad","iPhone","iPod"].indexOf(navigator.userAgent) > -1;

if(iOS) {
   $('body').css({ cursor : 'pointer' });
}

$('#html').on("click",function(e) {
    // No need for touch start click will do the trick;
});

iPhone没有检测到“点击”iPhone没有检测到“点击”你可以像这里提到的那样进行一些组合:你可以像这里提到的那样进行一些组合:@tipsfedora your welcome,不过,useragent检测并不是最好的解决方案,我建议你在空闲时间找一个更好的解决方案:)我应该建议你用更简单的解决方案取代正则表达式,如[“一”,“二”,“三]。indexOf(“一”)>=0(请记住等号!)我的想法是正则表达式是重引擎,indexOf是更节省资源的解决方案。好,这样就不行了。试试这个:[“iPad”、“iPhone”、“iPod”].indexOf(navigator.platform)>-1;|-|欢迎使用@tipsfedora,useragent detection并不是最好的解决方案,我建议你在空闲时间找一个更好的解决方案:)我应该建议你用更简单的解决方案取代正则表达式,比如[“一”,“二”,“三]。indexOf(“一”)>=0(记住等号!)我的想法是正则表达式是一个重引擎,indexOf是一种更节省资源的解决方案。好吧,这种方式不起作用。试试这个:[“iPad”、“iPhone”、“iPod”].indexOf(navigator.platform)>-1;|-|10倍至