JSFiddle - React, Tailwind, and code Playground
HTML
<input id="textbox1" value="This is tex box">
<input id="textbox2" value="This is another tex box">
JavaScript
$(function(){
$('input').each(function(){
var size = $(this).val().length;
alert(size);
$(this).attr('size',size);
});
});