title: How to get the ID of an active link
body: <p>I'd like to display the ID of the active link in my navbar through an alert, but I'm not sure how to do this with my current Bootstrap 3 classes.</p>
  
  <p>I was thinking of something like</p>
  
  <pre><code>alert( $('li').hasClass( "active" ).attr('id') );
  </code></pre>
  
  <p>but sadly that doesn't work.</p>
  
  <p><a href="http://www.bootply.com/FdJHhA9Bxf" rel="nofollow">Bootply</a></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="navbar navbar-inverse navbar-fixed-top"&gt;
              &lt;div class="container"&gt;
  
                  &lt;div class="collapse navbar-collapse navHeaderCollapse"&gt;
  
                      &lt;ul class="nav navbar-nav navbar-right"&gt;
  
                          &lt;li class = "active"&gt;&lt;a id = "tab1" href = "#" &gt;Link1&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a id="tab2" href = "#"&gt;Link2&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a id = "tab3" href = "#" &gt;Link3&lt;/a&gt;&lt;/li&gt;
  
                      &lt;/ul&gt;&lt;!-- END: "collapse navbar-collapse navHeaderCollapse" --&gt;
                  &lt;/div&gt;&lt;!-- END: "container" --&gt;
              &lt;/div&gt;&lt;!-- END: "container" --&gt;
  &lt;/div&gt;&lt;!-- END: "navbar navbar-inverse navbar-fixed-top" --&gt;
  </code></pre>