Check if Touch Device
//Check Mobile Devices
var checkMobile = function(){
//Check Device
var isTouch = ('ontouchstart' in document.documentElement);
//Check Device //All Touch Devices
if ( isTouch ) {
$('html').addClass('touch');
}
else {
$('html').addClass('no-touch');
};
};
//Execute Check
checkMobile();
Written by Greg Babula
Related protips
1 Response
We are in the process of redesigning a site of a client of ours and focusing heavily on mobile devices and mobile traffic. We have been making the site responsive and this jQuery snippet of yours has been extremely helpful! Thanks for posting/sharing. Cheers!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mobile
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#