Skip to content

Instantly share code, notes, and snippets.

@ckundo
Created April 9, 2013 17:18
Show Gist options
  • Save ckundo/5347552 to your computer and use it in GitHub Desktop.
Save ckundo/5347552 to your computer and use it in GitHub Desktop.
This js/jquery snippet will give focus to the first link in the main content area as defined by role='main'. This is a hack on top of the conventional 'skip navigation' link hack, that in many browsers does not change keyboard focus. It enhances the aria landmark role=main, which is widely supported by screen readers. Two birds with one stone.
// <a href="#" id="skip-nav">Skip Navigation</a>
// <div role='main'>
// <a href="#">This receives focus on clicking skip nav</a>
// </div>
$('#skip-nav').click(function(e) { $("[role='main'] a:first").focus(); e.preventDefault(); })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment