{"id":625,"date":"2012-05-29T04:57:50","date_gmt":"2012-05-29T04:57:50","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=625"},"modified":"2012-05-29T04:57:50","modified_gmt":"2012-05-29T04:57:50","slug":"jquery-get-selected-option-text-1-line-code","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-get-selected-option-text-1-line-code\/","title":{"rendered":"jQuery Get Selected Option Text Examples"},"content":{"rendered":"<p>If you wondering how to use <em><strong>jQuery to Get Selected Option Text<\/strong><\/em>, you have come to the right place. In this article, I am going to show you how to do just that with just 1 line of code.<!--more--><\/p>\n<h2>How to Get Selected Option Text using jQuery &#8211; Examples<\/h2>\n<p>Let us say that you have a select dropdown menu with multiple options. Let&#8217;s give this dropdown an id of &#8220;my_select&#8221;. Let&#8217;s assume that one of the options is selected (it does not matter which one). In such a case, the following is the code:<\/p>\n<h3>Example 1: Using option:selected<\/h3>\n<pre class=\"lang:xhtml decode:true\">$(\"#my_select option:selected\").text();<\/pre>\n<h3>Example 2: Using numeric value of the option<\/h3>\n<p>Let&#8217;s say that you know the value of specific option and want to get the text of that specific option. Let&#8217;s assume that the value of the option is &#8220;5&#8221; and you want to get it&#8217;s text. Here is how you can get it:<\/p>\n<pre class=\"lang:xhtml decode:true\">$(\"#my_select option[value='5']\").text();<\/pre>\n<h3>Example 3: Using non-numeric value of the option<\/h3>\n<p>If you have a non-numeric as the value for the options, then you may do the following to get it&#8217;s text:<\/p>\n<pre class=\"lang:xhtml decode:true\">$(\"#my_select option[value='some_value']\").text();<\/pre>\n<h5>That&#8217;s it!<\/h5>\n<p>Do you know of any other ways to use\u00a0<em><strong>jQuery to Get Selected Option Text<\/strong><\/em>? Feel free to share by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you wondering how to use jQuery to Get Selected Option Text, you have come to the right place. In this article, I am going to show you how to do just that with just 1 line of code.<\/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-625","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-a5","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/625","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=625"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/625\/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=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}