JSFiddle - React, Tailwind, and code Playground
HTML
<input id="first">
<input id="second">
<p>Auto-tab in 3 seconds... <span id="done" style="color:red"></span></p>
JavaScript
//simulates keydown of the tab key
function simulateTab() {
var TAB_KEY = 9;
var keyboardEvent = document.createEvent("KeyboardEvent");
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";
keyboardEvent[initMethod]("keydown", true, true, window, 0, 0, 0, 0, 0, TAB_KEY);
document.dispatchEvent(keyboardEvent);
}
//focus 'first' input
document.getElementById('first').focus();
//focus 'second' input after 3 seconds
setTimeout(function(){
document.getElementById('second').focus();
document.getElementById('done').innerHTML = 'Done!';
}, 3000);