Am I a touchdevice?
by mischah
HTML
<h1 id="test">Am I a touchdevice?</h1>
CSS
h1 {font-size: 30px; color: red;}
/* styling basics */
html {padding: 20px 0; background-color: #efefef;}
body {width: 80%; padding: 40px; margin: 0 auto; background: #fff; box-shadow: 1px 1px 5px rgba(0,0,0,0.5); font-family: Verdana, Arial, sans-serif; font-size: 14px;}
JavaScript
var is_touchdevice = 'ontouchstart' in document.documentElement;
if (is_touchdevice == true) {
document.getElementById("test").style.color = "green";
}