jQuery select first visible input

by helgatheviking

HTML

<form>
  <input type="hidden" value="hide" />

  <label>Select
    <select>
      <option value="a">A</option>
      <option value="b">B</option>
    </select>
  </label>



  <label>Text
    <input type="text" />
  </label>
  <label>
    Number

    <input type="number" />
  </label>


  <fieldset>
    <legend>
      Radios
    </legend>
    <label>A
      <input type="radio" value="a" />
    </label>
    <label>B
      <input type="radio" value="b" />
    </label>
  </fieldset>
</form>

CSS

input:focus,
select:focus,
radio:focus
{ border: 2px solid blue; }

JavaScript

//$('form').find( 'input:visible:first' ).trigger('focus');

$('form').find( ':input:enabled:visible:first').trigger('focus');