I am using jquery to load content into tabs, and switch the tabs on click. My problem is that one one page I am using this "tab switcher" twice, and it is causing a conflict. I am not too experienced with jquery, so my problem probably lies in the fact that I am creating the function twice in the head. Here is my jquery (you will notice that there are duplicate scripts, with the selectors changed up a bit so the "tab switchers" appear different.
<script type="text/javascript">
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
//When page loads...
$(".tabs_content").hide(); //Hide all content
$("ul.tab li:first").addClass("active").show(); //Activate first tab
$(".tabs_content:first").show(); //Show first tab content
//On Click Event
$("ul.tab li").click(function() {
$("ul.tab li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tabs_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
My css is all correct, I know the problem is above.The second script works fine, and the first script doesn't.
You can see this live here: link You will notice that the second script works fine (at the bottom : margie and todd. And the first script doesn't work (in the sidebar :categories and archives.)
Any idea how to fix this?