title: Get selected text from bootstrap dropdown
body: <p>I have a bootstrap dropdown, and I want to keep the text of what is selected. I have tried most of the ways tried here, <a href="https://stackoverflow.com/questions/30670294/get-value-from-html-drop-down-menu-in-jquery">Get Value From html drop down menu in jquery</a> , but there was never really an answer given, so I am still stuck.</p>
  
  <pre><code>&lt;div id="tableDiv" class="dropdown"&gt;
      &lt;button id="tableButton" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"&gt;
          Table
          &lt;span class="caret"&gt;&lt;/span&gt;
      &lt;/button&gt;
      &lt;ul id="tableMenu" class="dropdown-menu"&gt;
          &lt;li&gt;&lt;a href="#"&gt;Att1&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;Att2&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;Att3&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have a js function that looks as follows</p>
  
  <pre><code>$("#tableMenu").click(function(){
    var selText = $("#tableMenu").text();
    document.getElementById("tableButton").innerHTML=selText;
  });
  </code></pre>
  
  <p>but as explained in the above link, $("#tableMenu").text(); returns everything in the dropdown as a string, not just the one wanted. How do I get the text just from the one selected.</p>