-
-
Save krishna19/1661fedc5e719ac7626438f47b193008 to your computer and use it in GitHub Desktop.
jQuery - Mouse hover on touch devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taphover - a solution to the lack of hover on touch devices. | |
//more info: http://www.hnldesign.nl/work/code/mouseover-hover-on-touch-devices-using-jquery/ | |
$('a.taphover').on('touchstart', function (e) { | |
'use strict'; //satisfy the code inspectors | |
var link = $(this); //preselect the link | |
if (link.hasClass('hover')) { | |
return true; | |
} else { | |
link.addClass('hover'); | |
$('a.taphover').not(this).removeClass('hover'); | |
e.preventDefault(); | |
return false; //extra, and to make sure the function has consistent return points | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment