Last active
June 13, 2016 16:19
-
-
Save bueckl/9dc40013458a50c2777e876d98bac216 to your computer and use it in GitHub Desktop.
Make Dropdown Menu work on Touch devices
This file contains 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
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