Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6975007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:18:45+00:00 2026-05-27T17:18:45+00:00

The jQuery autogrow plugin expands textarea to fit their content. The function is as

  • 0

The jQuery autogrow plugin expands textarea to fit their content. The function is as follows.

(function($) {
    /*
     * Auto-growing textareas; technique ripped from Facebook
     */
    $.fn.autogrow = function(options) {

        this.filter('textarea').each(function() {

            var $this       = $(this),
                minHeight   = $this.height(),
                lineHeight  = $this.css('lineHeight');

            var shadow = $('<div></div>').css({
                position:   'absolute',
                top:        -10000,
                left:       -10000,
                width:      $(this).width(),
                fontSize:   $this.css('fontSize'),
                fontFamily: $this.css('fontFamily'),
                lineHeight: $this.css('lineHeight'),
                resize:     'none'
            }).appendTo(document.body);

            var update = function() {

                var val = this.value.replace(/</g, '&lt;')
                                    .replace(/>/g, '&gt;')
                                    .replace(/&/g, '&amp;')
                                    .replace(/\n/g, '<br/>');

                shadow.html(val);
                $(this).css('height', Math.max(shadow.height() + 20, minHeight));
            }

            $(this).change(update).keyup(update).keydown(update);

            update.apply(this);

        });

        return this;

    }

})(jQuery);

It is then triggered $('textarea').autogrow();. After a JQuery load function we load in a new textarea. Thus I triggered this.

$('.commentslogic').load(window.location.href + ' .commentslogic .inner', function(){
$('textarea').autogrow();
}); 

But it does not apply to the new textarea, furthermore there is no error reported in FireBug. Help!

Fiddle dee dee Fiddle dee dum http://jsfiddle.net/JTmND/8/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:18:45+00:00Added an answer on May 27, 2026 at 5:18 pm

    As figured out in the comments, this fiddle is the solution: http://jsfiddle.net/JTmND/11/

    $(document).ready(function() {
        $('textarea').autogrow();
    
        $('.button').click(function() {
            $('.test').html('<textarea></textarea>');
            $('.test').find('textarea').autogrow();
        });
    });
    

    It doesn’t matter how the new textareas are added to the dom (manually or by ajax callback method), it is necessary to use jquery selectors to assign the autogrow functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was playing around with the jquery autogrow plugin, which expands the height of
I'm using a plugin ( https://github.com/jaz303/jquery-grab-bag/blob/master/javascripts/jquery.autogrow-textarea.js ) that dynamically resizes textareas. To use it
I've been trying to find a good jquery auto grow plugin but every single
jQuery function: function refresh(ppp){ $(#content).load(process.php+ppp) } PHP process.php: $vID = $_REQUEST[id]; include page_$vID.php; The
I am using plugin here http://plugins.jquery.com/project/autogrow and I got a problem in Internet Explorer
Jquery has a great language construct that looks like this: $(document).ready(function() { $(a).click(function() {
jQuery's getScript function doesn't seem to support an error callback function. I can't use
There's a very simple jquery plugin: autotextarea. I'd like to teach it one little
jQuery mobile 1.0 I change the content of the page, to put it simple:
I am working on web application. I wanted to apply auto height to textarea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.