Auto resizing textarea link down jquery
<p>This link was referenced in another article about resizing a textarea.  The page (and website) is all down now.</p>

<p>Does anyone have the code that was on it for resizing a text area:</p>

<p><a href="http://javascriptly.com/examples/jquery-grab-bag/autogrow-textarea.html" rel="nofollow">http://javascriptly.com/examples/jquery-grab-bag/autogrow-textarea.html</a></p>

<p>EDIT now found below.  Just in case it goes down again:</p>

<pre><code>(function ($) {
    /*
     * Auto-growing textareas;
     */
    $.fn.autogrow = function (options) {
        this.filter('textarea').each(function () {
            var $this = $(this),
                minHeight = $this.height(),
                lineHeight = $this.css('lineHeight');
            var shadow = $('&lt;div&gt;&lt;/div&gt;').css({
                position: 'absolute',
                top: -10000,
                left: -10000,
                width: $(this).width() - parseInt($this.css('paddingLeft')) - parseInt($this.css('paddingRight')),
                fontSize: $this.css('fontSize'),
                fontFamily: $this.css('fontFamily'),
                lineHeight: $this.css('lineHeight'),
                resize: 'none'
            }).appendTo(document.body);
            var update = function () {
                    var times = function (string, number) {
                            for(var i = 0, r = ''; i &lt; number; i++) r += string;
                            return r;
                        };
                    var val = this.value.replace(/&lt;/g, '&amp;lt;').replace(/&gt;/g, '&amp;gt;').replace(/&amp;/g, '&amp;amp;').replace(/\n$/, '&lt;br/&gt;&amp;nbsp;').replace(/\n/g, '&lt;br/&gt;').replace(/ {2,}/g, function (space) {
                        return times('&amp;nbsp;', space.length - 1) + ' '
                    });
                    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);
</code></pre>
