【jquery】之touchstart和mousedown

点击事件是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;
    }
}

 

 

 

posted on 2014-02-07 16:03  毛毛_Roc  阅读(1690)  评论(0编辑  收藏  举报

导航