need help with some tabs ... i`m a newbie

Discussion in 'JavaScript' started by rober7, Sep 22, 2010.

  1. #1
    i have 3 tabs and i want to make active (when page loads) second tab. And i wonder if is possible to make tabs rotate (i read about this command .tabs( "rotate" , ms , [continuing] ) but i dont know where to put it)

    i use this code for my ajax tabs

    $(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;
    	});
    
    });
    Code (markup):

    and this for html


    <ul class="tabs">
        <li><a href="#tab1">Pages</a></li>
        <li><a href="#tab2">Categories</a></li>
    	<li><a href="#tab3">Follow us</a></li>
    </ul>
    
    <div class="tab_container">
        <div id="tab1" class="tab_content">
            x<!--Content-->
        </div>
    	
    	
        <div id="tab2" class="tab_content">
           y<!--Content-->
        </div>
    	
    	    <div id="tab3" class="tab_content">
           z<!--Content-->
        </div>
    	
    	
    	
    </div>
    Code (markup):
     
    rober7, Sep 22, 2010 IP