JSFiddle - React, Tailwind, and code Playground

by lexingtonpenguins

HTML

<input type="text" value="This input box is supposed to size to its contents onload"/><br>
<input type="text" value="And another input box"/><br>
<input type="text" value="More input boxes that change their sizes!"/>

JavaScript

$(document).ready(function () {
    $( "input[type='text']" ).each(function( index ) {
        $(this).attr("size", $(this).val().length );
    });
});