Get textarea value in jquery

Rate this post

Today, We want to share with you get textarea value in jquery.In this post we will show you how to get value in jquery, hear for Get Input Textbox Value and Textarea Value with Jquery we will give you demo and example for implement.In this post, we will learn about jquery get textarea value with an example.

How to Get all Textarea in a Form using JavaScript/jQuery Example

Example 1: index.html

<!DOCTYPE html>
<title>getElementByTagName() Example -</title>
  * { font: 17px 'Calibri'; } 
  ul { list-style: none; }
  textarea {
    height: 3em;
    width: 20em;
    padding: 5px;

  	Click the button below to get all the textarea elements only!
  <div style='border:solid 1px #ccc;'>
    <!--I have three textarea elements.-->
    <ul><li><textarea id="a1"></textarea></li></ul>
    <ul><li><textarea id="a2"></textarea></li></ul>
    <ul><li><textarea id="a3"></textarea></li></ul>

    <input type="text" id="txt1" placeholder='Enter your name'>
    <input type="button" id="bt1" value='Submit' onclick='getTArea()'>

let getTArea = () => {
    const ele = document.getElementsByTagName('textarea');

    for (let i = 0; i <= ele.length - 1; i++) {
      if (ele[i].value != '')
      	alert (ele[i].value);
      else {
      	alert ('Enter some value.');
        return false;

Example 2: Use the jQuery val() Method

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Set Textarea Value -</title>
<script src=""></script>
        var textContent = "The quick brown fox jumps over the lazy dog.";
    <textarea id="commentBox" rows="3" cols="50"></textarea>
    <button type="button">Set Textarea Value</button>

Example 3: using JavaScript

<textarea id="commentBox">
Hello World

  var x = document.getElementById("commentBox").value;

Example 4: jquery get textarea text

$('input#mybutton').click(function() {
    var text = $('textarea#mytextarea').val();
    //send to PHP server and process response

Free Live Chat for Any Issue

Example 5:



I hope you get an idea about How to set the content of a textarea using jQuery?.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.