JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" />
<input type="text" />
<a href="#">test link</a>
<input type="text" />
<select>
    <option>test</option>
</select>
<a href="#">test link</a>
<textarea>hey!</textarea>

<a href="#">test link</a>
<button>button me?</button>

JavaScript

$(document).ready(function() {

    //gather all inputs of selected types
    var inputs = $('input, textarea, select, button');

    //bind on keydown
    inputs.on('keydown', function(e) {
        
        //if we pressed the tab
        if (e.keyCode == 9 || e.which == 9) {
            
            //prevent default tab action
            e.preventDefault();
            
            //get next input based on the current input we left off
            var nextInput = inputs.get(inputs.index(this) + 1);
            
            //if we have a next input, go to it. or go back
            if (nextInput) {
                nextInput.focus();
            }
            else{
                inputs[0].focus();
            }
        }
    });
});