Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//taphover - a solution to the lack of hover on touch devices.
//more info:
$('a.taphover').on('touchstart', function (e) {
'use strict'; //satisfy the code inspectors
var link = $(this); //preselect the link
if (link.hasClass('hover')) {
//preventDefault and return false will cause any other touches on the element(s) to fail.
//to avoid this behavior data() will store the "href". so "href" can be restored.
} else {
$('a.taphover').not(this).removeClass('hover');"href", link.attr("href")).removeAttr("href").css("cursor","pointer");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment