2012-07-22 17 views

回答

0

您可以參閱jQuery UI Tabs documentation你的問題,它很好地提到

var $tabs = $('#example').tabs(); // first tab selected 

$('#my-text-link').click(function() { // bind click event to link 
    $tabs.tabs('select', 2); // switch to third tab 
    return false; 
}); 
0

您可以自由使用選擇method以下索引選項卡之間切換。 一個例子:

$("#tabs").tabs('select', 1); 

連接這個片段對第一標籤內容的鏈接的點擊處理程序。

例子:

對於這樣一個鏈接:

<a href="some.html" id="nextTab">Go to Next Tab</a> 

的jQuery:

$("#nextTab").click(function() { 
    $("#tabs").tabs('select', 1); 
}); 
+0

感謝您的幫助,爲了保持選定的選項卡,我們必須在最後返回false。 – Hardworker 2012-07-23 02:58:42

+0

我面臨的另一個問題是,我在一個標籤上使用cookie的全回發,但問題是關閉頁面後,打開回以前選擇的標籤即將到來我希望顯示默認選項卡,任何人都可以幫助對此? – Hardworker 2012-07-23 03:16:43

0

比方說您初始化您的標籤如:

$('#tabs').tabs(); 

您可以選擇/通過編程導航到不同的標籤,如:

$('#tabs').tabs('select', index); 
// Where index start from 0, 
// 0 for the first tab, 1 for the second, and 2 for the third and so on 

比方說您在第一個選項卡的鏈接, 導航到上點擊第二個選項卡,你可以這樣做這樣的:

$('#link_in_first_tab').click(function (event) { 
    $('#tabs').tabs('select', 1); 
    event.preventDefault(); 
}); 

更多API的使用請參考jQuery UI的頁面: http://jqueryui.com/demos/tabs/

相關問題