Last Updated: November 19, 2020
· moak

Resize Textarea to fit Content

When users type and add or remove new lines the textarea re-sizes to fit the same number of lines

$('#content').on( 'change keyup keydown paste cut', 'textarea', function (){
}).find( 'textarea' ).change();

Check dat fiddle

Related protips:

jQuery: When to use $(document).ready() and when $(window).load()

2 Responses
Add your response

Excellent thanks :)
I have tweaked this a little to use it as an extension:

autoresize: function () {
$(this).on('change keyup keydown paste cut', function () {


over 1 year ago ·

I signed up just tell you thank you for sharing, Mark. It was exactly what I needed. I added #content{overflow:hidden;} to get rid of the quick scroll bar that shows up when it resizes.

over 1 year ago ·