Get textarea value in jQuery

textarea value using jQuery

In web applications while using textarea control, we need to get the value of textarea at client side. In this post we will see example of how to get value of textarea in jQuery.

Example to get textarea value in jQuery

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="development-bundle/jquery-1.7.1.js" type="text/javascript"></script>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<title>Get textarea value in jQuery</title>
<script type="text/javascript">
$(document).ready(function () {
$("#submitbtn").click(function () {
var textAreaValue = $("#txtMessage").text();
alert(textAreaValue);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<textarea cols="50" rows="5" id="txtMessage"></textarea>
<input type="button" id="submitbtn" value="Submit" />
</div>
</form>
</body>
</html>