Skip to content

Instantly share code, notes, and snippets.

@SebAshton
Created November 27, 2012 12:02
Show Gist options
  • Save SebAshton/4153892 to your computer and use it in GitHub Desktop.
Save SebAshton/4153892 to your computer and use it in GitHub Desktop.
Gist to bypass all hover events for elements with .hover-bypass on touch devices
/*
* Usage: add class of .hover-bypass to all element with
* hover effects that aren't intended for touch
* users
* Credit: Something https://github.com/chrisblackburn wrote
*/
/* Coffee */
(($) ->
if typeof window.ontouchstart isnt "undefined"
$(".hover-bypass").live "mouseover", ->
$(this).click()
false
) jQuery
/* JS */
(function($) {
if (typeof window.ontouchstart !== 'undefined') {
return $('.hover-bypass').live('mouseover', function() {
$(this).click();
return false;
});
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment