Wednesday, March 28, 2012

Make textarea auto-height as you type using jQuery

jQuery is one of the most popular JavaScript frameworks, a fast and concise library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.

To make a textarea's height increase as you type, use the following script:
  $('#mytextarea').keyup(function(event){
    if($(this).scrollTop()){
        $(this).height($(this).scrollTop()+$(this).height());
    }
  });

1 comment:

  1. Thank you, I was looking for a simple, quick and clean solution, appreciate the help ! =o)

    ReplyDelete