2011-03-24 85 views
4

我的問題很簡單。如何檢查一個選項卡是否被點擊?

我有2個選項卡,我想提醒我將要在選項卡中選擇

$('#social_edit_pannels').tabs({ 
    select: function(event, ui) { 
     var firstSelect = $('#tabs').tabs('option', 'selected'); 
     alert(firstSelect); 

     if (firstSelect == 0) { 
      alert("0"); 
     } 
     else if (firstSelect == 1) { 
      alert("1"); 
     } 
    } 
}); 

只是這個例子檢查爲已經點擊標籤..

什麼想法?

+3

那麼你有什麼問題?這有點不清楚。 – Groovetrain 2011-03-24 22:30:00

回答

4

聽起來好像你想知道哪個選項卡剛剛被選中,但是使用你得到的選項卡是以前選擇的。

只要叫ui.index,如果你想要的元素它是jsfiddleui.tab

$('#social_edit_pannels').tabs({ 
    select: function(event, ui) { 
     var theSelectedTab = ui.index; 
     if (theSelectedTab == 0) { 
      alert("0"); 
     } 
     else if (theSelectedTab == 1) { 
      alert("1"); 
     } 
    } 
}); 

代碼示例。

+0

太棒了,它的工作。 – Patrioticcow 2011-03-24 23:33:18

相關問題