Detect Touch device
Straight from Modernizer.
var is_touch_device = function() {
var bool;
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
bool = true;
}
return bool;
};
if(is_touch_device()) {
$("html").addClass("touch");
}
Written by Greg
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Touch event
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#