Created
October 30, 2012 19:45
-
-
Save eliorivero/3982538 to your computer and use it in GitHub Desktop.
Drop down menus for iPad
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 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