jquery get textarea value

Today, We want to share with you jquery get textarea value.In this post we will show you how to fetch value of text area in ajax, hear for how to get ckeditor value in jquery we will give you demo and example for implement.In this post, we will learn about JQuery Validate CKEditor Value Is Blank Or Not with an example.

how to get the value of a textarea in jquery?

html textarea jquery value

Example 1:
Value of text area is also taken with val method:

var message = $('textarea#message').val();

textarea value jquery set

Example 2:

<!DOCTYPE html> 
<html> 
	<head> 
		<title>How to get the value of text Area</title> 
		<script src= 
"https://code.jquery.com/jquery-1.12.4.min.js"> 
		</script> 
	</head> 
	<body> 
		<center> 
			<h2 style="color: green;">Pakainfo</h2> 
			<textarea id="txtArea"></textarea><br><br> 
			<button id="btn">Show Text</button> 
		</center> 
	</body> 

	<script> 
		$(document).ready(function () { 
			
			$("#btn").click(function () { 
				
				var txt = $("#txtArea").val(); 
				alert(txt); 
			}); 
		}); 
	</script> 
</html> 

Use the jQuery val() method

Example 3:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fetch Value from Text area in jQuery</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
    $(document).ready(function(){
        $("button").click(function(){
            var comment = $.trim($("#comment").val());
            if(comment != ""){
                // You can use the jQuery val() method to get or set the value of a <textarea> element.
                alert(comment);
            }
        });
        
    });
</script>
</head>
<body>
    <textarea id="comment" rows="5" cols="50"></textarea>
    <p><button type="button">Get Value</button></p>
    <p><strong>Note:</strong> You can use the jQuery val() method to get or set the value of a <textarea> element.</p>
</body>
</html>

I hope you get an idea about jquery retrive text area value.
I would like to have feedback on my infinityknow.com 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.