Skip to content

Instantly share code, notes, and snippets.

@javan
Created December 29, 2012 04:05
Show Gist options
  • Save javan/4404503 to your computer and use it in GitHub Desktop.
Save javan/4404503 to your computer and use it in GitHub Desktop.
Remove :hover styles from mobile browsers
if 'createTouch' of document
ignore = /:hover\b/
try
for stylesheet in document.styleSheets
idxs = []
# detect hover rules
for rule, idx in stylesheet.cssRules
if rule.type is CSSRule.STYLE_RULE and ignore.test(rule.selectorText)
idxs.unshift idx
# delete hover rules
stylesheet.deleteRule idx for idx in idxs
@sinak
Copy link

sinak commented Feb 6, 2015

Just wanted to point anyone who lands here to https://gist.github.com/sweatpantsninja/5400379, which is based on this gist but only removes the specific selectors with :hover, rather than the entire css rule.

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