{"id":564,"date":"2014-11-10T08:09:19","date_gmt":"2014-11-10T08:09:19","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=564"},"modified":"2014-11-10T09:58:17","modified_gmt":"2014-11-10T09:58:17","slug":"how-to-get-selected-option-in-jquery","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/how-to-get-selected-option-in-jquery\/","title":{"rendered":"How to get selected option in jquery"},"content":{"rendered":"<p>How to set a Specific option as selected<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;script src=&quot;jquery-2.1.0.min.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;\r\n\t&lt;script&gt;\r\n\t $('document').ready(function(){\r\n\t   $('#btnSubmit').click(function(){\r\n            alert($('#cboLocation').val());\r\n            alert($('#cboLocation').find(&quot;:selected&quot;).text());\r\n\t\t\t});\r\n\t\t});\r\n\t&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;select name=&quot;cboLocation&quot;  id=&quot;cboLocation&quot;&gt;\r\n  &lt;option value=&quot;&quot;&gt;Select Zone&lt;\/option&gt;\r\n  &lt;option value=&quot;South&quot;&gt;South Chennai&lt;\/option&gt;\r\n  &lt;option value=&quot;North&quot;&gt;North Chennai&lt;\/option&gt;\r\n  &lt;option value=&quot;East&quot;&gt;East Chennai&lt;\/option&gt;\r\n  &lt;option value=&quot;West&quot;&gt;West Chennai&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n&lt;input type=&quot;button&quot; name=&quot;btnSubmit&quot; id=&quot;btnSubmit&quot; value=&quot;Click Me&quot;\/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>How to get Selected Item Value<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n alert($('#cboLocation').val());\r\n<\/pre>\n<p><strong>How to get Selected Item Text<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n alert($('#cboLocation').find(&quot;:selected&quot;).text());\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to set a Specific option as selected &lt;html&gt; &lt;head&gt; &lt;script src=&quot;jquery-2.1.0.min.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt; &lt;script&gt; $(&#8216;document&#8217;).ready(function(){ $(&#8216;#btnSubmit&#8217;).click(function(){ alert($(&#8216;#cboLocation&#8217;).val()); alert($(&#8216;#cboLocation&#8217;).find(&quot;:selected&quot;).text()); }); }); &lt;\/script&gt; &lt;\/head&gt; &lt;body&gt; &lt;select name=&quot;cboLocation&quot; id=&quot;cboLocation&quot;&gt; &lt;option value=&quot;&quot;&gt;Select Zone&lt;\/option&gt; &lt;option value=&quot;South&quot;&gt;South Chennai&lt;\/option&gt; &lt;option value=&quot;North&quot;&gt;North Chennai&lt;\/option&gt; &lt;option value=&quot;East&quot;&gt;East Chennai&lt;\/option&gt; &lt;option value=&quot;West&quot;&gt;West Chennai&lt;\/option&gt; &lt;\/select&gt; &lt;input type=&quot;button&quot; name=&quot;btnSubmit&quot; id=&quot;btnSubmit&quot; value=&quot;Click Me&quot;\/&gt; &lt;\/body&gt; &lt;\/html&gt; How to get Selected Item&hellip; <a href=\"https:\/\/codethataint.com\/blog\/how-to-get-selected-option-in-jquery\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-jquery"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=564"}],"version-history":[{"count":9,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":568,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/564\/revisions\/568"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}