JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="one" placeholder="Type two chars" />
<input type="text" id="two" placeholder="It should focus here" />
<br />
<input type="button" id="three" value="Click this" />
<input type="text" id="four" placeholder="It focuses here" />
<br />
<input type="text" id="five" placeholder="Type two chars" />
<input type="text" id="six" placeholder="It will change this text" />
JavaScript
$(document).ready(function() {
$("#one").on("keyup paste",function() {
console.log($(this).val());
if($(this).val().length == 2) { $("#two").focus(); }
});
$("#three").click(function() {
$("#four").focus();
});
$("#five").on("input", null, null, function() {
if($("#five").val().length == 2) { $("#six").val("It works!"); }
});
});