记录一下我个人用的两种方式,仅供参考。
第一种:
if(/Android|webOS|iPhone|ipad|BlackBerry/i.test(navigator.userAgent)) {
此处写判断内容....
} else {
此处写PC判断内容....
}
第二种:
if(screen.width <= 750){
此处写移动端判断内容....
} else {
此处写PC判断内容....
}
可参考链接:https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery