How Would I Detect Touch Screens In Jquery And Hide A Div
How would I use this code: function is_touch_device() { return !!('ontouchstart' in window) // works on most browsers || !!('onmsgesturechange' in window); // works on ie1
Solution 1:
You would simply call the function and use basic logic.
if (is_touch_device()) {
$('.yourclass').hide();
}
Solution 2:
It would be implemented like this:
window.onload=function(){
if (is_touch_device()){
var divs=document.getElementsByClassName( 'yourclassname');
for (var i=0; i<divs.length; i++)
divs[i].style.display='none';
}
}
functionis_touch_device() {
return !!('ontouchstart'inwindow) // works on most browsers
|| !!('onmsgesturechange'inwindow); // works on ie10
};
Post a Comment for "How Would I Detect Touch Screens In Jquery And Hide A Div"