Skip to content

Instantly share code, notes, and snippets.

@terkel
Created September 23, 2011 00:55
Embed
What would you like to do?
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