YogeshChauhan . com

How to auto-resize textarea based on text input using JavaScript or jQuery?

in JavaScript & jQuery on March 30, 2021

All we need to do is just increase the height if the text input is beyond the height of the textarea.

We can do that using JavaScript scrollheight method.

Here’s another post on scrollHeight.

How to get the height and width of an element using JavaScript?

jQuery Solution

Check the demo out:

JavaScript Solution

We can access the textarea elements using Tag Name

Checkout the demo:

There are plenty of other ways to do it as you can see in these answers on StackOverflow.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

New to ┬áDrupal? Here’s What You Need to KnowDrupalHow to load a module with configuration in SCSS?SCSSHow to control file extensions with an .htaccess file?MiscHow to select multiple values in React dropdown?ReactCan we execute conditions in SQL?SQL/MySQLHow to change CSS with jQuery?CSSKilling A Project Part 1: What criteria should be used to cancel/kill a project?MiscPHP __construct() functionPHPCan We Use For Loop to Loop Through Associative Arrays in PHP?PHPHow to add new elements with swing animation using JavaScript and CSS?CSSSQL Right JoinSQL/MySQLUnary Operators in JavaScriptJavaScript