title: Retrieving id of a <li> element with certain class
body: <p>I have a problem retrieving an ID of a "li" element which I would use in AJAX.</p>
  
  <pre><code>&lt;div id="subTab"&gt;
      &lt;ul class="nav nav-pills" style="display:none" id="users"&gt;
          &lt;li id="AUser"&gt;&lt;a href="#AUser"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; User Management&lt;/a&gt;&lt;/li&gt;
          &lt;li id="ARole"&gt;&lt;a href="#ARole"&gt;Role Management&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>With ajax using this code I add "active" class to the "li" element:</p>
  
  <pre><code>$(this).closest('ul li').addClass('active');
  </code></pre>
  
  <p>So my question is, how to retrieve the ID attribute of li that would have the active class in it?
  I tried lots of ways, but none of them were successful..</p>
  
  <pre><code>$('#subTab').find('li .active').attr('id');
  </code></pre>
  
  <p>this one returns nothing.</p>
  
  <pre><code>$('#subTab').find('ul li').closest('.active').attr('id');
  </code></pre>
  
  <p>this one returns the "ul" elements id..</p>
  
  <p>If anyone has a solution, please help me solve this,
  Thank you for your time.</p>