0

When the DOM is loaded, i want to check all my textareas and change their height depending on the text contained. It should look something like that:

 $().ready(function (){
     //my check textares code
 });

Can anyone give me advice how to do that? Thanks.

m90
  • 11,434
  • 13
  • 62
  • 112
Anton Sementsov
  • 1,196
  • 6
  • 18
  • 34
  • Sounds like to me you haven't made an attempt and are looking for someone to give you the answer, in which case you have come to the wrong place. Come back when you actually have a specific question and some workings of your own. – dapperwaterbuffalo Apr 13 '12 at 13:33
  • What code do you already have, did you try searching for something like: "auto adjust size textarea". http://bit.ly/IDgBS5 – Gert Van de Ven Apr 13 '12 at 13:33
  • Ofc i tried, there are a lot of plugins, which do that on fly, when text typing by user, but i don`t wont to use plugins, think that can be done in some easy way. – Anton Sementsov Apr 13 '12 at 13:35
  • Have you looked at how those plugins work? Figure out what methods make those plugins work and you'll know how to implement it yourself. – Surreal Dreams Apr 13 '12 at 13:37
  • possible duplicate http://stackoverflow.com/questions/1288297/jquery-auto-size-text-input-not-textarea – coder Apr 13 '12 at 13:45
  • Check this http://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize – Krish Apr 13 '12 at 13:55

2 Answers2

0

Since you use jquery, you might as well use plugin jgrow for that

Artjom Kurapov
  • 6,115
  • 4
  • 32
  • 42
0

you should use jquery plugin Autosize.

you can download this: http://www.jacklmoore.com/autosize

just declare like this:

$(document).ready(function(){
    $('textarea').autosize();  
});
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123