JSFiddle - React, Tailwind, and code Playground
by pradeep777
HTML
<select>
<option value="33">Select me</option>
<option value="1">1</option>
</select>
<input type='radio' checked="true" />
<input type='text' />
<input type='checkbox' checked=""/>
<input type='text' value=' howdy ' />
<input type='button' />
<textarea></textarea>
JavaScript
$("input:enabled,select:enabled,textarea:enabled").filter(function () {
return this.type.match(/checkbox|radio/i) && //when it's a checkbox/radio
!this.checked || //get me a list of unselected ones
($.trim(this.value) === ""); // else get me a list of empty inputs
}).first().focus(); //grab the fist from the list and set focus