Last active
December 14, 2015 16:29
-
-
Save luckyshot/5115177 to your computer and use it in GitHub Desktop.
Detect if is a touch device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* TOUCH DEVICE | |
* Detects touch devices | |
* Usage: if (is_touch_device) { yes! } | |
*/ | |
var is_touch_device = 'ontouchstart' in document.documentElement; | |
/** | |
* CSS class method | |
* Detects touch devices | |
*/ | |
if ( !!('ontouchstart' in window) ) | |
{ | |
$('html').addClass( 'touch' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment