JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="first" name="first" size="11" value="this has 11">
<br>
<input type="text" id="second" name="second" size="11" value="12345678901">
<br>
<input type="text" id="third" name="third" size="22" value="this has 22 characters">
<br>
<input type="text" id="jQ" name="jQ" value="text, text, text">

JavaScript

$("#jq").attr("size", $("#jQ").val().length );