2012-06-27 89 views
0

我正在使用jquery選項卡來顯示一些內容,我需要在選項卡內打開另一個選項卡,我的jQuery知識非常有限,因此我是張貼我的代碼,所以你可以檢查並看看我能做什麼?jquery選項卡,打開選項卡中的鏈接

這是jQuery代碼:

$(document).ready(function() { 
    //$(".tab_content").hide(); 
    $(".tab_content").css({ 
     'display':'block', 
     'position':'absolute', 
     'top':'-999em', 
     'left':'-999em' 
    }); 
    //$(".tab_content:first").show(); 
    $(".tab_content:first").css({ 
     'top':'350px', 
     'left':'50px', 
     'width':'660px' 
    }); 
    firstTabHeight = $(".tab_content:first").height(); 
    $(".tab_content:first").parent().css('height',firstTabHeight); 

    $("#nav-portfolio ul li").click(function() { 
     $("#nav-portfolio ul li").removeClass("active"); //Remove any "active" class 
     $(this).addClass("active"); //Add "active" class to selected tab 
     //$(".tab_content").hide(); //Hide all tab content 
     $(".tab_content").css({ 
      'display':'block', 
      'position':'absolute', 
      'top':'-999em', 
      'left':'-999em' 
     }); 

     var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
     $(activeTab).hide(); 
     //$(".tab_content").css({ 
     // 'opacity':'0', 
     //}); 
     //var tabHeight = $(activeTab).height(); 
     //$('#colLeft').height(tabHeight); 
     $(activeTab).fadeIn(); //Fade in the active content 
     thisTabHeight = $(activeTab).height(); 
     $(activeTab).css({ 
      'display':'block', 
      'position':'relative', 
      'top':'0', 
      'left':'0', 
      'width':'660px' 
     }); 
    activeTabHeight = $(activeTab).height(); 
    $(".tab_content:first").parent().css('height',activeTabHeight); 

    return false; 

    }); 

回答

0

綁定點擊功能,以您的選項卡里面的鏈接給你打電話想去的標籤的點選功能。例如,如果你想鏈接觸發第二個標籤:

$('#this_is_the_link').click(function(e) { 
    e.preventDefault(); //stop the normal link function from happening 
    $("#nav-portfolio ul li:nth-child(2)").click() // call click event on the second tab 
}); 
相關問題