Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including jquery-autoexpand with all npm packages installed. Try it out:

var jqueryAutoexpand = require("jquery-autoexpand")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

jquery-autoexpand v1.0.2

Auto-expands textareas so they grow as you type.

jquery-autoexpand

A textarea will automatically grow and shrink in height as you add or remove content to it.

  • The textarea will never shrink smaller than its original height
  • The textarea will never grow beyong the bottom edge of the window. Instead, a scroll bar show up in the textarea as more text as added to the textarea.

Usage

$('textarea').autoExpand();

Or if you want to customize some of the options:

$('textarea').autoExpand({ animationTime: 0, windowPadding: 100 });

Remove

If you no longer need the textarea to auto-expand and you want to reset it:

$('textarea').autoExpand('destroy');

Options

Options can be passed in as a { key: value } object literal. Available options are:

propertydefault valuedescription
animationTime50Time in milliseconds to animate to new height
windowPadding20Amount of pixels to preserve between textarea & window bottom

You can remove the auto-expander from a textarea by passing 'destroy' (as string, not in an object literal).

Installation

Install this package via npm:

npm install jquery-autoexpand

Or simply copy jquery.autoexpand.js into your project.

License

jquery-autoexpand is MIT licensed.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free