Skip to content

Instantly share code, notes, and snippets.

@eliorivero
Created October 30, 2012 19:45
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 eliorivero/3982538 to your computer and use it in GitHub Desktop.
Save eliorivero/3982538 to your computer and use it in GitHub Desktop.
Drop down menus for iPad
function isTouch() {
try {
document.createEvent('TouchEvent');
return true;
} catch(e) {
return false;
}
}
jQuery(document).ready(function($) {
if( isTouch() ){
// Menu/sub menu structure is ul > li > a + ul.sub-menu > li
$('.sub-menu').parent().children('a').each(function(){
var $a = $(this);
$a.on('touchend', function(e){
$a.toggleClass('dontgo');
if ($a.hasClass('dontgo')) {
e.preventDefault();
$a.removeClass('dontgo');
return false;
}
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment