2010-11-01 126 views

回答

1

如果點擊存在ui-tabs-selected類你可以檢查。假設你使用的是標準的標記:

// in your click event 
var selected_exists = $('#yourTabBox') 
    .children('ul.ui-tabs-nav') 
    .children('li.ui-tabs-selected') 
    .length; 

if (selected_exists) { 
    // Nothing is collapsed 
} else { 
    // collapsed 
} 

這是完美的select事件。

+0

@Stephen ......他認爲他可能會告訴我們他試過什麼或什麼? ';)'......當然會很高興知道他在和誰打架呢? – jcolebrand 2010-11-01 20:31:06

+1

@drachenstern:同意。如果我們所描述的不起作用,我們需要查看一些已經嘗試過的示例以及一些標記。 – Stephen 2010-11-01 20:33:37

+1

很好的答案(+1,如果我還有任何投票!)。注意在'select'事件中,'this'是外部div元素,所以你的代碼可以簡化爲'$(this).children('ul.ui-tabs-nav> li.ui-tabs-selected 「).length'。稍快,更靈活。 – lonesomeday 2010-11-01 20:38:51

1

show event怎麼樣?因爲你不知道哪個隱藏了?

甚至可能是你想要的select event。使用'tabsselect'事件

$(".selector").tabs({ 
    collapsible: true, 
    select: function(event, ui) 
    { 
     var prevSelectedIndex = $(".selector").tabs('option', 'selected'); 
     var nextSelectedIndex = ui.index; 

     if(prevSelectedIndex === -1) 
     { 
      // It was previously collapsed and the user is now opening 
      // tab at index: nextSelectedIndex 
     } 
     else if(prevSelectedIndex === nextSelectedIndex) 
     { 
       // The user has clicked on the currently opened 
       // tab and it is collapsing 
     } 
    } 
}); 
+1

我遇到了這個問題,並用你的答案。我添加了一段代碼來展示我如何使用它以備將來參考。 – 2012-08-03 02:22:27

相關問題