Skip to content

Instantly share code, notes, and snippets.

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
You can’t perform that action at this time.