Skip to content

Instantly share code, notes, and snippets.

@benzkji
Created July 8, 2017 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benzkji/32a511d22dfe79b5c69bdde47a5bbd85 to your computer and use it in GitHub Desktop.
Save benzkji/32a511d22dfe79b5c69bdde47a5bbd85 to your computer and use it in GitHub Desktop.
is-touch?
document.addEventListener('touchstart', function addtouchclass(e){ // first time user touches the screen
document.documentElement.classList.add('is-touch') // add "can-touch" class to document root using classList API
document.removeEventListener('touchstart', addtouchclass, false) // de-register touchstart event
}, false)
@benzkji
Copy link
Author

benzkji commented Jul 8, 2017

https://www.quora.com/How-do-I-disable-the-hover-CSS-rule-for-iPhone-and-iPad-touch-device-browsers/answer/John-Miller-386

funny that on stackoverflow you almost wont find this solution, which is, at least for me, quite superior to other solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment