Hi friends,
I have prblem that I need to view tab #2 when loading the index page, here is part of the index, it goes to tab1 as per the javascript function below (.tab_content:first).show, I tried (.tab_content:second).show but it did not work! Also I was unable to activiate first class.. Thanks a lot!
/////index page
$("ul.tabs li:").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
<ul class="tabs">
<li><a href="#tab1">tab2</a></li>
<li><a href="#tab2">tab2</a></li>
<li><a href="#tab3">tab3</a></li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content">
<!--Content--> </div>
<div id="tab2" class="tab_content">
<!--Content--> TAB 2
</div>
<div id="tab3" class="tab_content">
<!--Content--> TAB 3
</div>
</div>
//////// the javascript function:
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
[COLOR="Red"]$("ul.tabs li:").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content[/COLOR]
//On Click Event
$("ul.tabs li").click(function() {
// alert ($(document));
$("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
//alert ($(activeTab).value);
return false;
});
});