Skip to content

Instantly share code, notes, and snippets.

@bueckl
Last active June 13, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bueckl/9dc40013458a50c2777e876d98bac216 to your computer and use it in GitHub Desktop.
Save bueckl/9dc40013458a50c2777e876d98bac216 to your computer and use it in GitHub Desktop.
Make Dropdown Menu work on Touch devices
function isTouchDevice() {
return 'ontouchstart' in document.documentElement;
}
// Hack to make dropdown menu work on touch devices
var el = $('#main-nav ul.nav > li.dropdown-large a.dropdown-toggle');
/* If mobile browser, prevent click on parent nav item from redirecting to URL */
if ( isTouchDevice() ) {
$(el).click(function(event) {
event.preventDefault();
$(el).click(function(event) {
event.preventDefault();
location.href = $(el).attr('href');
});
});
} else {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment