title: How to get value of selected dropdown value on button click in jquery
body: <p>I am using Bootstrap with jquery to create a dynamic table consisting dropdown menu and button.
  I want to get value of dropdown menu selected in jquery on button click.</p>
  
  <p>Below is my code</p>
  
  <pre><code>&lt;table class="table table-bordered"&gt;
    &lt;tbody&gt;
    {% for item in items %}
      &lt;tr&gt;
        &lt;td&gt;
          &lt;div class="dropdown"&gt;
            &lt;button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
              Select
            &lt;/button&gt;
            &lt;ul class="dropdown-menu" role="menu" id="options" onchange="selectFromDropDown(this.value)"&gt;
              &lt;li&gt;&lt;a id="weekly" selected&gt;Option 1&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a id="biweekly"&gt;Option 2&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a id="monthly"&gt;Option 3&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/td&gt;
        &lt;td&gt;
          &lt;form data-toggle="validator" role="form" &gt;
            &lt;input type="submit" value="Update" class="btn btn-xs btn-block" id="update"&gt;
          &lt;/form&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      {% endfor %}
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And below is the jquery</p>
  
  <pre><code>$('#update').click(function(){
    alert($('#options option:selected').html())
  });
  </code></pre>
  
  <p>When I run above code it returns "undefined".</p>