Automatic Textarea Resizer In Vanilla JavaScript

Category: Form , Javascript | August 12, 2020
Author:shaack
Views Total:37 views
Official Page:Go to website
Last Update:August 12, 2020
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
});

You Might Be Interested In:


Leave a Reply