Automatic Textarea Resizer In Vanilla JavaScript

Category: Form , Javascript | June 14, 2021
Author: shaack
Views Total: 10 views
Official Page: Go to website
Last Update: June 14, 2021
License: MIT

Preview:

Automatic Textarea Resizer In Vanilla JavaScript

Description:

A Vanilla JavaScript plugin to automatically adjust the height of the textarea while typing.

Supports the native paste event and works with the latest Bootstrap framework.

How to use it:

1. Insert the JavaScript file auto-resize-textarea.js into the document.

<script src="src/auto-resize-textarea.js"></script>

2. Attach the autoResizeTextarea plugin to your textarea element and done.

<textarea class="form-control"></textarea>
autoResizeTextarea(document.querySelectorAll("textarea.form-control"));

3. Specify the max height of the textarea.

autoResizeTextarea(document.querySelectorAll("textarea.form-control"),{
  maxHeight: 140
});

Changelog:

v1.1.3 (06/14/2021)

  • demo update

v1.1.2 (04/05/2021)

  • When containing text and < maxHeight show the full text

v1.1.1 (03/12/2021)

  • Bugfix

You Might Be Interested In:


Leave a Reply