{"id":1324,"date":"2012-10-07T05:56:04","date_gmt":"2012-10-07T05:56:04","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=1324"},"modified":"2012-10-07T05:56:04","modified_gmt":"2012-10-07T05:56:04","slug":"jquery-get-textarea-value-get-textarea-value-when-button-is-clicked","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-get-textarea-value-get-textarea-value-when-button-is-clicked\/","title":{"rendered":"jQuery Get Textarea Value when button is clicked Examples"},"content":{"rendered":"<p>If you ware wondering how to <em><strong>find or\u00a0get Textarea Value \u00a0using jQuery<\/strong><\/em>, then this article is for you. Many times web designers\/developers happen to work with forms and at times, it might be very essential to find the textarea value. In this article, I am going to show you how to find the textarea value very easily, when button is clicked using few examples. So read on to find out more.<!--more--><\/p>\n<h2>How to Find \/ Get Textarea Value using jQuery<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1324\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>For the sake of the example, lets assume that we have a textarea with ID &#8220;comments&#8221;. So now we will get the value entered in this textarea using jQuery. Following is the HTML source code:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;Example&lt;\/title&gt;\n&lt;script type=\"text\/javascript\" src=\"js\/jquery-1.8.2.min.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n&lt;form name=\"form1\" method=\"post\" action=\"\"&gt;\n&lt;p&gt;\n&lt;label for=\"comments\"&gt;Comments&lt;br&gt;\n&lt;\/label&gt;\n&lt;textarea name=\"comments\" id=\"comments\" cols=\"45\" rows=\"5\"&gt;&lt;\/textarea&gt;\n&lt;\/p&gt;\n&lt;p&gt;\n&lt;input type=\"checkbox\" name=\"get_comm_val\" id=\"get_comm_val\"&gt;\n&lt;label for=\"get_comm_val\"&gt;Alert Textarea Value?&lt;\/label&gt;\n&lt;\/p&gt;\n&lt;p&gt;\n&lt;input type=\"submit\" name=\"sbt_get_val\" id=\"sbt_get_val\" value=\"Alert Textarea Value\"&gt;\n&lt;\/p&gt;\n&lt;\/form&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<h3>Example 1: Alert theTextarea Value when button is clicked<\/h3>\n<pre class=\"lang:js decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\n$('#sbt_get_val').on(\"click\", function(e){\n\nvar textarea_val = $('#comments').val()\n\nalert( 'Textarea value is: \\n'+ textarea_val );\n\ne.preventDefault();\n\n});\n\n&lt;\/script&gt;<\/pre>\n<h3>Example 2: Alert the Textarea Value when Checkbox is clicked<\/h3>\n<pre class=\"lang:js decode:true crayon-selected\">&lt;script type=\"text\/javascript\"&gt;\n\n$('#get_comm_val').on(\"click\", function(e){\n\nif( $(this).is(\":checked\") )\n{\nvar textarea_val = $('#comments').val()\n\nalert( 'Textarea value is: \\n'+ textarea_val );\n}\n\n});\n\n&lt;\/script&gt;<\/pre>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1324\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<h5>Easy?<\/h5>\n<p>Do you know of any other ways to <em><strong>get the textarea value using jQuery<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you ware wondering how to find or\u00a0get Textarea Value \u00a0using jQuery, then this article is for you. Many times web designers\/developers happen to work with forms and at times, it might be very essential to find the textarea value. In this article, I am going to show you how to find the textarea value [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[40,42,41],"class_list":["post-1324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-2","tag-jquery-demos-2","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-lm","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=1324"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1324\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=1324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=1324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=1324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}