title: How to get Selected element in bootstrap dropdown, where dropdown is dynamically populated
body: <p>This is similar to
  <a href="https://stackoverflow.com/questions/13437446/how-to-display-selected-item-in-bootstrap-button-dropdown-title">How to Display Selected Item in Bootstrap Button Dropdown Title</a></p>
  
  <p>Only difference, my dropdown list is not static and it is populated through ajax response.
  Below code <strong>doesn't work only for</strong> <code>&lt;li&gt;</code> items which are populated dynamically. </p>
  
  <p>To test above, I intentionally put a static <code>&lt;li&gt;</code> when I click on that item, I can see success message in console. But, when I click on <code>&lt;li&gt;</code> which are appended dynamically, I don't get anything in console.</p>
  
  <p>I believe, there is some jQuery fundamental knowledge I missing here. jQuery gurus, comments/thoughts?</p>
  
  <p>Here is some code for further clarification.</p>
  
  <p>Java Script Code:</p>
  
  <p>Printing selected option in console</p>
  
  <pre><code>$(".dropdown-menu li a").click(function () {
          console.log("Selected Option:"+$(this).text());
  });
  </code></pre>
  
  <p>Populating dropdown from ajax JSON response</p>
  
  <pre><code>$.each(response, function (key, value) {
      $("#dropDownUL").append("&lt;li&gt; &lt;a tabindex=\"-1\" href=\"#\" align=\"left\"&gt; " + value + "&lt;/a&gt; &lt;/li&gt;");
  })
  </code></pre>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;div class="dropdown btn"&gt;
      &lt;div id="dropDownId" class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#"&gt;
          Collections
          &lt;b class="caret"&gt;&lt;/b&gt;
      &lt;/div&gt;           
      &lt;ul id="dropDownUL"  class="dropdown-menu pull-left" role="menu" aria-labelledby="dLabel"&gt;
      &lt;li&gt;&lt;a tabindex="-1" href="#" align="left"&gt;Static test Option&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  
  
  &lt;/div&gt;
  </code></pre>
  
  <p>So, once again, if I click on <code>Static test Option</code> I can see message in console : <code>Selected Option: Static test Option</code></p>
  
  <p>But, when I click on <code>Option2</code> <code>Option 3</code> which is populated from ajax response, I don't see anything in console.</p>
  
  <p>Let me know if something is not clear. I will try to explain further.</p>