Skip to content

Instantly share code, notes, and snippets.

@djom202
Forked from fastcodecoq/Focus.js
Last active August 29, 2015 14:11
Show Gist options
  • Save djom202/b2bbd2a0d109905486bc to your computer and use it in GitHub Desktop.
Save djom202/b2bbd2a0d109905486bc to your computer and use it in GitHub Desktop.
(function($){
$.fn.Focus = function(){
$(this).focus();
$(this).attr('autofocus','');
}
$(function(){
$("*[autofocus]").focus();
$("*[data-autofocus]").focus();
$("*[autoFocus]").focus();
});
})(jQuery);
// uso
// $('element').Focus();
// <input data-autofocus>
// <input autofocus>
// <input autoFocus>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment