Automatically resize textareas as content grows
Quick and easy:
$('textarea').on 'scroll', ->
if @scrollHeight > @clientHeight
@style.height = @scrollHeight + "px";
Compatibilty
All the way down to IE6 if you use jQuery or similar for the "scroll" event, IE9+ otherwise.
Sources:
- matching textarea's size to its content: MDN HTMLTextAreaElement)
- scroll event compatibility on quirksmode
Written by Stefano B.
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ui
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#