title: jQuery if statement for finding element ID
body: <p>I have a group of tabs that have hidden content which display when the tab is clicked.  The jQuery looks like this:</p>
  
  <pre><code>jQuery(document).ready(function($){
   var sections = $('.section').hide();
  
   $('.tablink').click(function(e){
          e.preventDefault();
          sections.hide();
          $($(this).attr('href')).show();
          $(this).closest('ul').find('li').removeClass('active');
          $(this).closest('li').addClass('active');
   });
  
   var tab = getParameterByName('tab');
   if(tab)
      $('.tablink:eq('+(tab-1)+')').click();
   else
       $('#section1').show();  //show first section
  });
  </code></pre>
  
  <p>The HTML looks like this:</p>
  
  <pre><code>  &lt;li id="tab1" class="active"&gt;&lt;a class="tablink" href="#section1"&gt;Link1&lt;/a&gt;&lt;/li&gt;
    &lt;li id="tab2"&gt;&lt;a class="tablink" href="#section2"&gt;Link2&lt;/a&gt;&lt;/li&gt;
    &lt;li id="tab3"&gt;&lt;a class="tablink" href="#section3"&gt;Link3&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>I'm trying to figure out how to add an additional function to the tab click that says:</p>
  
  <p>if #tab2 has the class .active then do X.</p>
  
  <p>This seems very straight forward, but I can't get it.  Ideas?</p>