LoginSignup
15
13

More than 5 years have passed since last update.

タッチデバイス判定

Posted at

タッチデバイスを判定するには?

javascript
function isTouchDevice() {
  var result = false;
  if (window.ontouchstart === null) {
    result = true;
  }  
  return result;
}

if (isTouchDevice()) {
  console.log('touch device');
} else {
  console.log('not touch device');
}
15
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13