Automatic Textarea Resizer In Vanilla JavaScript

Category: Form , Javascript | May 29, 2023
Author:shaack
Views Total:64 views
Official Page:Go to website
Last Update:May 29, 2023
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.6 (05/29/2023)

  • renamed querySelector to elements

v1.1.5 (09/06/2021)

  • code formatting

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