js 检测 touch 设备

检测 touch 设备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 var isPC, hClick='click';
if ('ontouchstart' in window) {
$('body').addClass('is-touch');
isPC = false;
hClick = 'touchstart';
} else {
$('body').addClass('no-touch');
isPC = true;
}


$('.nav-tabs').once('.active').each(function () {
if (!isPC) {
$('.navbar-toggle').on(hClick, function() {
......
})
}
})