I am currently finalising a simple website for a project I'm working on. I have two tab controls. One on the right of the page, and one on the left. Both have 3 tabs that when clicked display different content. I created one a while ago, and it has worked perfectly, I have recently returned and tried to add a second one. The problem is, when the page loads, the first one works, but the second one loads with all three content areas displayed down the page. Oddly, once I click one of the tabs on the second controller, only that tab is displayed, and the entire control seems to work correctly just like the other one.
I'm sure I have made a stupid error, but I just cant seem to find it. Any help would be massively appreciated.
My code is below:
<div id="graphWrapper">
<ul class="tabs">
<li><a href="#" class="defaulttab" rel="tabs1">Daily</a></li>
<li><a href="#" rel="tabs2">Gender</a></li>
<li><a href="#" rel="tabs3">Age</a></li>
</ul>
<div class="tab-content" id="tabs1">Graph Content 1</div>
<div class="tab-content" id="tabs2">Graph Content 2</div>
<div class="tab-content" id="tabs3">Graph Content 3</div>
</div>
<div id="reportWrapper">
<ul class="tabs2">
<li><a href="#" class="defaulttab2" rel2="tabsR1">Report 1</a></li>
<li><a href="#" rel2="tabsR2">Report 2</a></li>
<li><a href="#" rel2="tabsR3">Report 3</a></li>
</ul>
<div class="tab-content2" id="tabsR1">Report Content 1</div>
<div class="tab-content2" id="tabsR2">Report Content 2</div>
<div class="tab-content2" id="tabsR3">Report Content 3</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script>
$(document).ready(function() {
$('.tabs2 a').click(function(){
switch_tabs2($(this));
});
switch_tabs($('.defaulttab'));
switch_tabs2($('.defaulttab2'));
});
function switch_tabs(obj)
{
$('.tab-content').hide();
$('.tabs a').removeClass("selected");
var id = obj.attr("rel");
$('#'+id).show();
obj.addClass("selected");
chart3.invalidateSize();
chart4.invalidateSize();
chart5.invalidateSize();
}
function switch_tabs2(obj2)
{
$('.tab-content2').hide();
$('.tabs2 a').removeClass("selected2");
var id2 = obj2.attr("rel2");
$('#'+id2).show();
obj2.addClass("selected2");
}
</script>