Last Updated: February 25, 2016
·
540
· gregbenner

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");
        }