Here’s a handy little snippet to automatically put the cursor in the first input field on the page. You can override it by adding a class of “nofocus” to any element and/or list the elements in the array. Nice for login pages.
if( !$(':input:visible:enabled:first').hasClass('nofocus') &&
$.inArray( $(':input:visible:enabled:first').attr('id'),
['element_to_exclude', 'another_element_to_exclude']
) == -1
){
$(':input:visible:enabled:first').focus();
}