It's fairly straightforward. I want to set focus to the first enabled and not hidden control on the page.
For a textbox, I have
$("input[type='text']:visible:enabled:first").focus();
But I want to get "all" form input controls: textbox, checkbox, textarea, dropdown, radio in my selector to grab the first enabled and not hidden control. Any suggestions?
$(':input:enabled:visible:first').focus();
As an extension of Jordan's answer
$(':input:enabled:visible:not([readonly]):first').focus();
This one also excludes readonly inputs
This is a little more comprehensive:
$('form :input:text:visible:not(input[class*=filter]):first').focus();
Lamen: Focus the cursor in the first text input in a form that is visible, but if it use the class named "filter", ignore it!
Try this:
$("input[type='text']:enabled","another selector","another selector").first().focus();