Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created April 18, 2012 04:38
Show Gist options
  • Save james2doyle/2411137 to your computer and use it in GitHub Desktop.
Save james2doyle/2411137 to your computer and use it in GitHub Desktop.
add touch style pseudo class to touch-ed elements
//remove tap-highlight-color from all in css
// a[data-active] { /* here are your styles */ }
element.addEventListener("touchstart", function (event) {
if (event.target.setAttribute) {
event.target.setAttribute("data-active", "");
}
}, true);
element.addEventListener("touchend", function (event) {
if (event.target.removeAttribute) {
event.target.removeAttribute("data-active");
}
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment