{"id":742,"date":"2012-06-04T19:16:45","date_gmt":"2012-06-04T19:16:45","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=742"},"modified":"2012-06-04T19:16:45","modified_gmt":"2012-06-04T19:16:45","slug":"jquery-textarea-value-get-set-append-to-textarea-value","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-textarea-value-get-set-append-to-textarea-value\/","title":{"rendered":"jQuery Textarea Value Examples (Using Get, Set, Append)"},"content":{"rendered":"<p>Ever wondered how to <em><strong>Get Textarea value, Set Textarea value &amp; Append to Textarea value using jQuery<\/strong><\/em>? In this article, I am going to show you easy ways of doing all the above. Actual code is just 1 line, so it&#8217;s super easy to follow and implement.<!--more--><\/p>\n<h2>Examples to Get, Set, Append To Textarea value<\/h2>\n<p>Let&#8217;s say you have a textarea with ID &#8220;comments&#8221;.<\/p>\n<h3>Example 1: Get Textarea value using jQuery:<\/h3>\n<p>This code simply gets the existing value of the textarea.<\/p>\n<pre class=\"lang:js decode:true\">$(\"#comments\").val();<\/pre>\n<h3>Example 2: Set Textarea value using jQuery:<\/h3>\n<p>This code sets the value of the textarea to &#8220;This is my custom text.&#8221;. Note that it WILL OVERWRITE any of the existing textarea value.<\/p>\n<pre class=\"lang:js decode:true\">$(\"#comments\").val('This is my custom text.');<\/pre>\n<h3>Example 3: Append to Textarea value using jQuery:<\/h3>\n<p>If you do not want the existing textarea value to be overwritten and would instead want a new value to be appended to the existing value, then use the following code:<\/p>\n<pre class=\"lang:js decode:true\">$('#comments').val( $('#comments').val() + 'This new text will be appended to existing value in textarea.' );<\/pre>\n<h5>Simple, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to <em><strong>Get, Set and Append to Textarea value using jQuery<\/strong><\/em>? Feel free to share by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wondered how to Get Textarea value, Set Textarea value &amp; Append to Textarea value using jQuery? In this article, I am going to show you easy ways of doing all the above. Actual code is just 1 line, so it&#8217;s super easy to follow and implement.<\/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":[41],"class_list":["post-742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-bY","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/742","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=742"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/742\/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=742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}