I have a group of tabs that have hidden content which display when the tab is clicked. The jQuery looks like this:
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
});
The HTML looks like this:
<li id="tab1" class="active"><a class="tablink" href="#section1">Link1</a></li>
<li id="tab2"><a class="tablink" href="#section2">Link2</a></li>
<li id="tab3"><a class="tablink" href="#section3">Link3</a></li>
I'm trying to figure out how to add an additional function to the tab click that says:
if #tab2 has the class .active then do X.
This seems very straight forward, but I can't get it. Ideas?