title: How to access value from dynamic drop down list using Javascript/ jquery
body: <p>I have created a dynamic drop down list. I want to access the value selected from the dynamically created drop down. 
  My HTML file </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>&lt;/head&gt;
  &lt;body&gt;
      &lt;table align="center" cellspacing="3" cellpadding="3"&gt;
          &lt;tr&gt;
              &lt;td&gt;County Name: &lt;/td&gt;
              &lt;td&gt;&lt;select id="county"&gt;&lt;option value=""&gt;Select county&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;City: &lt;/td&gt;
              &lt;td&gt;&lt;select id="city"&gt;&lt;option value=""&gt;Select city&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;button  class="btn" onclick="doThis()""&gt;Go&lt;/button&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>My js file:</p>
  
  <pre><code>    function doc(id){return document.getElementById(id);}
          function buildCounty(){
              var opts=doc('county').options;
              for(var i=0;i&lt;arr.length;i++){
                  opts[opts.length]=new Option(arr[i][0],arr[i][0]);
              }
              doc('county').onchange=function(){
                  this.blur();
                  var val=this.value;
                  if(!val){return;}
                  var co=doc('city').options;
                  co.length=1;
                  for(var j=0;j&lt;arr.length;j++){
                      if(arr[j][0]!==val){continue;}
                      else{
                          var temp=arr[j][1];
                          for(var k=0;k&lt;temp.length;k++){
                              co[co.length]=new Option(temp[k],temp[k]);
                          }
                          break;
                      }
                  }
              }
          }
          function doThis(){
  
          }
          window.onload=buildCounty;
      &lt;/script&gt;
  </code></pre>
  
  <p>On click of the button, doThis() function existing in js file is called. In that function, I want to access the value selected in the 2nd (City list) dropdown.</p>