Created
September 23, 2011 00:55
-
-
Save terkel/1236495 to your computer and use it in GitHub Desktop.
HTML5 Autofocus Polyfill using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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