Yogesh Chauhan's Blog

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.

Most Read

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

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
Learn how to give a temporary name to a column or to a table using SQL AliasesSQL/MySQLHow to disable the Recovery Mode in WordPress?WordPressHow to create a pricing table using flex in CSS?CSSList of social media icon logo color codes in HEXMiscellaneousEXISTS and NOT EXISTS in PostgresPostgresThe SQL UNION OperatorSQL/MySQLHow to verify your domain in Google Console with a TXT record?MiscellaneousHow to list all PHP variables to debug the script?PHPHow to show and hide an element on click in React?ReactSQL Right JoinSQL/MySQLA Quick Guide to Object-Oriented Programming in PHPPHPHow to Access a Global Variable From Inside a Function in PHP?PHP