点击事件是html开发中最常用的事件,而jquery里面有click,mousedown,mouseup,touchstart,touchend等事件函数可以调用。

 

在mobile上,必须要用touchstart,可以用以下函数进行判断。

 

function detectmob() {
    if( navigator.userAgent.match(/Android/i)
        || navigator.userAgent.match(/webOS/i)
        || navigator.userAgent.match(/iPhone/i)
        || navigator.userAgent.match(/iPad/i)
        || navigator.userAgent.match(/iPod/i)
        || navigator.userAgent.match(/BlackBerry/i)
        || navigator.userAgent.match(/Windows Phone/i)
    ) {
        return true;
    }else{
        return false;
    }
}

 

 

 

相关文章:

  • 2022-01-03
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案