我如何在jquery中检测触摸屏并隐藏div

Ash*_*coe 1 html javascript css jquery detection

我将如何使用此代码:

function is_touch_device() {
  return !!('ontouchstart' in window) // works on most browsers 
      || !!('onmsgesturechange' in window); // works on ie10
}; 
Run Code Online (Sandbox Code Playgroud)

检测触摸屏并隐藏一组具有相同类别的div.

Mic*_*yen 5

您只需调用该函数并使用基本逻辑.

if (is_touch_device()) {
  $('.yourclass').hide();
}
Run Code Online (Sandbox Code Playgroud)