auto-resize-textarea.js | Resizing Textarea Automatically with JavaScript

auto-resize-textarea.js is light javascript textarea plugin, it can resize the height of the textarea automatically when you are typing.

auto-resize-textarea.js - Resizing Textarea Automatically with JavaScript

AuthorLinksMade withLast update
shaackOffice HomeJavaScriptSep 18, 2020

How to resize textarea using auto-resize-textarea.js?

1.Import auto-resize-textarea.js in html page

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

2.Bind html textarea element using autoResizeTextarea() function

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

3.You also can use maxHeight to set the maximum height of html textarea

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

Leave a Reply

Your email address will not be published. Required fields are marked *