title: jQuery: Show textbox on specific condition
body: <p>When user select United States I show textbox for US city but what if user deselect the United States?</p>
  
  <p>How could I check if there is <strong>United States</strong> selected or not if not the hide City textbox.
  <img src="https://i.stack.imgur.com/HP88y.png" alt="enter image description here">
  my script is:</p>
  
  <pre><code>&lt;tr&gt;
  &lt;td nowrap="nowrap"&gt;
  &lt;label for="countryId"&gt;Countries&lt;/label&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;select id="countryId" onchange="usCity();" multiple="multiple" name="countryId[]"&gt;
  &lt;option value="1"&gt;United States&lt;/option&gt;
  &lt;option value="2"&gt;United Kingdom&lt;/option&gt;
  &lt;option value="3"&gt;Australia&lt;/option&gt;
  &lt;option value="4"&gt;UAE&lt;/option&gt;
  &lt;option value="5"&gt;Denmark&lt;/option&gt;
  &lt;option value="6"&gt;Czech Republic&lt;/option&gt;
  &lt;option value="7"&gt;Brazil&lt;/option&gt;
  &lt;option value="8"&gt;Singapore&lt;/option&gt;
  &lt;option value="9"&gt;Pakistan&lt;/option&gt;
  &lt;option value="10"&gt;Germany&lt;/option&gt;
  &lt;option value="11"&gt;India&lt;/option&gt;
  &lt;option value="12"&gt;SriLanka&lt;/option&gt;
  &lt;option value="13"&gt;UK&lt;/option&gt;
  &lt;option value="14"&gt;Algeria&lt;/option&gt;
  &lt;option value="15"&gt;Andorra&lt;/option&gt;
  &lt;option value="16"&gt;Caneda&lt;/option&gt;
  &lt;option value="17"&gt;HongKong&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;td valign="top"&gt;
  &lt;/tr&gt;
  &lt;tr id="usCitytr" style="display: none;"&gt;
  &lt;td nowrap="nowrap"&gt;
  &lt;label for="USCity"&gt;US City Name&lt;/label&gt;
  &lt;/td&gt;
  &lt;td colspan="3"&gt;
  &lt;input id="USCity" type="text" value="" name="USCity"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  function usCity()
      {
          if ($("#countryId option:selected").text() == 'United States' || $("#countryId option:selected").text() == 'US'){
              $("#usCitytr").show();
          }
      }
  </code></pre>
  
  <p>I thing on each selection I have to get all selected values in array structure and then using loop to find 'US' if found then show 'US City' textbox else hide. For this I used</p>
  
  <pre><code>alert($('select#countryId').text());
  </code></pre>
  
  <p>but it returns all values present in combobox. How ever         </p>
  
  <pre><code>alert($('select#countryId').val());
  </code></pre>
  
  <p>returns only selected value but I need 'US' not the index where 'US' is present because 'US' might be any where.</p>