jQuery textarea auto-grow, auto-height

Ever wondered how sites such as Facebook create that cool auto-grow, auto-height type thing on textarea’s? Where you begin typing and the textarea automatically adjusts its own height to accommodate the text you’ve entered so far. Its awesome, and funny enough, I’ve got the same feature on the comments on this blog.

Its done by one simple, awesome jQuery script from this site.

Once downloaded and referenced in your <head> section, lob this code on your site (making sure you reference your own textarea correctly) and it’ll do its magic…

$(document).ready (function() {
    $('textarea.expanding').autogrow({
        maxHeight: 100,
	minHeight: 30,
	lineHeight: 16
    });
})

See the demo here. Awesome stuff – respect for the author, not me! :)

 

3 comments about jQuery textarea auto-grow, auto-height

  1. nahl says:

    good really great

  2. vickie says:

    the jquery works fine. But the alignment for this textarea box have error on chrome and safari :D

  3. jacob says:

    Hi,
    Nice tutorial.

    Btw nice layout too. Especialy that lake at the top.

    Regards,
    Jacob

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>