Javascript Textarea Height Fit Content

Related Post:

Javascript Textarea Height Fit Content - function FitToContent (id, maxHeight) { var text = id && id.style ? id : document.getElementById (id); if ( !text ) return; var adjustedHeight = text.clientHeight; if ( !maxHeight || maxHeight > adjustedHeight ) { adjustedHeight = Math.max (text.scrollHeight, adjustedHeight); if ( maxHeight ) adjustedHeight = Math.min (maxHeight, adju... If you dont mind a scollbar inside the text area you can use document ready function tx textarea tx height tx prop scrollHeight and here is a Fiddle another Fiddle this has min and max width set but with plug ins like auto size the height of the text box increases with input or you can try this plug in

Javascript Textarea Height Fit Content

Javascript Textarea Height Fit Content

Javascript Textarea Height Fit Content

1 Here's a modern solution (uses one line of JS and some CSS wizardry): codepen. - Oliver Dec 27, 2020 at 11:59 @yashas123 the problem with that is that it does not handle, e.g., a textarea which has input longer than the height of the browser window (neither does max-height: 100%, etc) - Taylor D. Edmiston May 22 at 17:47 The above example demonstrates a number of features of