I would like to focus on the first element of the page using jQuery when the page is loaded. I could successfully set the focus for the first element using
$(":input:visible:first").focus();
or
$(':input:enabled:visible:first').focus();
according to jquery, focus on the first allowed input or select or text box on the page .
I tried using any of the below:
$('select:first').focus();
$("select").first().focus();
$(':visible:first').focus();
$('enabled:visible:first').focus();
or other options that I could think of, but failed.
Can someone help me in solving this problem? I am new to jQuery.
I would like this feature to work for all major browsers.
Many thanks!
source
share