Skip to content

Instantly share code, notes, and snippets.

@terkel
Created September 23, 2011 00:55
Show Gist options
  • Save terkel/1236495 to your computer and use it in GitHub Desktop.
Save terkel/1236495 to your computer and use it in GitHub Desktop.
HTML5 Autofocus Polyfill using jQuery
(function ($) {
$(function () {
if (!supportsInputAttribute('autofocus')) {
$('[autofocus=]').focus(); // http://bugs.jquery.com/ticket/5637
}
});
// detect support for input attirbute
function supportsInputAttribute (attr) {
var input = document.createElement('input');
return attr in input;
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment