Skip to content

Instantly share code, notes, and snippets.

@Xtremefaith
Created December 10, 2013 18:55
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 Xtremefaith/7896053 to your computer and use it in GitHub Desktop.
Save Xtremefaith/7896053 to your computer and use it in GitHub Desktop.
Ever have trouble getting hover effects to work on mobile devices that don't have :hover events? Sub-menus are a common area with this problem, here is a snippet of how you can resolve that.
/*!
Fix for iOS touch/hover event with submenus
*/
$('.nav .parent').on('click', function(){
  $(this).find('.submenu').slideToggle('fast');
});
$(document).on('touchstart click', function(){
  if(!$(this).hasClass('.parent')){
    $('.parent .submenu').fadeOut('fast');
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment