Skip to content

Instantly share code, notes, and snippets.

@fastcodecoq
Last active August 29, 2015 14:11
Show Gist options
  • Save fastcodecoq/2d1aee7d8a4040f6f493 to your computer and use it in GitHub Desktop.
Save fastcodecoq/2d1aee7d8a4040f6f493 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