{"id":683,"date":"2012-05-30T08:56:32","date_gmt":"2012-05-30T08:56:32","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=683"},"modified":"2012-05-30T08:56:32","modified_gmt":"2012-05-30T08:56:32","slug":"jquery-value-jquery-val","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-value-jquery-val\/","title":{"rendered":"jQuery Value ( val() ) Examples"},"content":{"rendered":"<p>Ever wondered how to <strong>get the value of of a form element using jQuery<\/strong>? In this article, \u00a0I am going to show you different ways to use<strong> <em>jQuery to get value of input elements<\/em><\/strong>.<!--more--><\/p>\n<h2>How to use .val() method in jQuery to get Value<\/h2>\n<p>The most easiest way to get the value of an input element is to use the\u00a0<strong>.val() method<\/strong>.<\/p>\n<p>This can be used on\u00a0form elements such as input, textarea and\u00a0select.<\/p>\n<h3>Example 1:\u00a0Get value of an input box with ID &#8220;state&#8221;<\/h3>\n<pre class=\"lang:js decode:true\">$('#state').val();<\/pre>\n<h3>Example 2:\u00a0Get value of an textarea with ID &#8220;comments&#8221;<\/h3>\n<pre class=\"lang:js decode:true\">$('#comments').val();<\/pre>\n<p>Example 3:\u00a0Get value of a selected option of a select dropdown with ID &#8220;country&#8221;<\/p>\n<pre class=\"lang:js decode:true\">$('#country option:selected').val();<\/pre>\n<h3>Example 4:\u00a0Another way to get value of a dropdown with ID &#8220;country&#8221;<\/h3>\n<pre class=\"lang:js decode:true\">$('#country').val();<\/pre>\n<h3>Example 5:\u00a0Get value of a checkbox with ID &#8220;subscribe&#8221;<\/h3>\n<pre class=\"lang:js decode:true\">$('#subscribe:checked').val();<\/pre>\n<h3>Example 6:\u00a0Get value of a radio button with ID &#8220;gender&#8221;<\/h3>\n<pre class=\"lang:js decode:true\">$('#gender:checked').val();<\/pre>\n<h5>That&#8217;s it!<\/h5>\n<p>Do you know of any other implementations of using\u00a0<strong><em>jQuery to get value by using .val(); method<\/em><\/strong>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wondered how to get the value of of a form element using jQuery? In this article, \u00a0I am going to show you different ways to use jQuery to get value of input elements.<\/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-683","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-b1","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/683","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=683"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/683\/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=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}