We can use jQuery to clear a textarea field easily by making use of the jQuery val() method. We simply need to set the value of the textarea to an empty string.


Let’s see a quick example of this below:

Let’s say we have the following HTML:

The textarea in the example above will have the text “This is some default text.”. If we want to clear the textarea in the example above, we would use the following jQuery code:


If you are using WordPress, don’t forget to change the $ to jQuery as below:


We can also clear a textarea field using just plain JavaScript by targeting the value property.

Let’s do an interactive example of clearing a textarea below.

Using jQuery to Set and Clear a textarea Field with a Click

Below we will have a simple textarea input. It will start prefilled with some text from our about page. We will then let the user clear the textarea.

Here is our simple HTML:

Clear text above

We will simply use the jQuery val() method to set the textarea field to an empty string.

Here is the JavaScript and jQuery code:

  //That's it!

The final code and output for this example of using jQuery to clear a textarea field is below:

Code Output:

Clear text above

Full Code:

Clear text above

Hopefully this article has been useful to help you understand how to use jQuery to clear a textarea.

Categorized in:


Last Update: April 1, 2024