How to Change Data or Value of Textarea with JavaScript

Textarea is an essential part of a form on websites. There are many use cases where you need textarea in forms like the contact us page, feedback page, or a simple chat UI. This example explains how to set data/content or value of a textarea input field.

How to Change Data or Value of a Text Area

There is no need to use jQuery or other libraries like Alpine JS just to change the value of a textarea input. You can use vanilla JS for this purpose. The following example explains how you can change the value of textarea with vanilla JavaScript.

You can check the working example that will look like the following screenshot.

In the example above, you will be able to change the textarea content after clicking on the button.


A simple code snippet of vanilla JavaScript is enough to change the textarea value instead of using jQuery or another library. You can easily update the value of a textarea input with JavaScript .value method.


Latest articles

Related articles