8

I'm trying to find the best textarea autogrow plugin. I need one which resizes the textarea even when I paste into it. Any idea?

Hirvesh
  • 7,636
  • 15
  • 59
  • 72

9 Answers9

7

Elastic is a very good one, and it handles CTRL + V cases too.

You can visit the website and try out a demo.

labilbe
  • 3,501
  • 2
  • 29
  • 34
4

This is the one I ended up using. Working great so far!

http://www.jacklmoore.com/autosize/

The JQuery Elastic plugin is slow and didn't work for me in IE8.

Pete Montgomery
  • 4,060
  • 3
  • 30
  • 40
4

Why not use it?? http://plugins.jquery.com/project/autogrowtextarea

Or another updated version of this plugin here: https://github.com/ro31337/jquery.ns-autogrow

Roman Pushkin
  • 5,639
  • 3
  • 40
  • 58
Manish Trivedi
  • 3,481
  • 5
  • 23
  • 29
  • doesn't autoresize on paste... :( – Hirvesh Feb 19 '11 at 12:45
  • I had issues with the jquery.ns-autogrow cause of certain styling choices. I used the autosize.js and it worked out of box and with one line of code to set the auto size. – Rob Mar 11 '16 at 16:07
2

I used the following method, in jQuery.

setInterval(function(){
      $(name_textarea).css('height', $(name_textarea)[0].scrollHeight+2+'px')
},100);

Try it, you could possibly change the scrollHeight to obtain the best results.

Lokesh A. R.
  • 2,326
  • 1
  • 24
  • 28
Gaucho_9
  • 265
  • 1
  • 3
  • 11
1

You can try Advanced Textarea. Download from http://www.jscripts.info

  • Auto-Height Textarea
  • Returns Plain Text and HTML Content
  • Automatic URL and Email recognition
  • HTML Tags Filter
john
  • 11
  • 1
0

i made another one plugin to do this, check it here: https://github.com/AndrewDryga/jQuery.Textarea.Autoresize

Andrew Dryga
  • 692
  • 2
  • 7
  • 21
0

"I need one which resizes the textarea even when I paste into it"

this method also listen for copy/paste events: https://stackoverflow.com/a/5346855/4481831

I think on modern browsers those events can be replaced with "input" event, but on older browser this method will not work.

Community
  • 1
  • 1
crisc2000
  • 1,082
  • 13
  • 19
0

Auto-expand of text area can be accomplished without plugin. For example:

 var change_textarea = function() {
   jQuery('#your_textarea').on( 'change keyup keydown paste cut', 'textarea', 
   function(){
     jQuery(this).height(0).height(this.scrollHeight);
   }).find( 'textarea' ).change();  
 }  

And do not forget to call the function on document ready:

  jQuery(document).ready(function() {
     change_textarea();
  )};
Bud Damyanov
  • 30,171
  • 6
  • 44
  • 52
-1

Here is another plug, that also support horizontal growing of text areas:

https://github.com/dgbeck/jquery.autogrow-textarea

It is also based on the "mirror" approach but falls back to simple math in IE 8 and lower, since the mirror approach leads to textareas that grow too quickly in IE <= 8.

Brave Dave
  • 1,300
  • 14
  • 9