cirosantilli.github.io
cirosantilli.github.io copied to clipboard
HTML TextArea resize automatically
https://stackoverflow.com/questions/17283878/html-textarea-resize-automatically/25566993#25566993
The autosize jQuery plugin https://github.com/jackmoore/autosize just works and is quite popular (1.5k GitHub stars, cdnjs):
http://jsfiddle.net/cirosantilli/35ch4jxz/
<textarea id="autosize" style="width:200px;">a
b
c</textarea>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/autosize.js/1.18.4/jquery.autosize.min.js"></script>
<script>$('#autosize').autosize()</script>
And if you are using the ACE editor, use maxLines: Infinity: https://stackoverflow.com/questions/11584061/automatically-adjust-height-to-contents-in-ace-cloud9-editor