0
我動態地添加和刪除標籤。我現在嘗試通過指數去一個特定的標籤如下:jquery uitabs off by -1
var elem = ('[role="tabpanel"][symbol="'+symbol+'"][exchange="'+exchange+'"]');
var index = $(elem).index();
$("#tabs").tabs({active: index});
相關的HTML代碼:
<div id="tabs-1" aria-labelledby="ui-id-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" style="display: none;"></div>
<div id="tabs-2" aria-labelledby="ui-id-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" style="display: none;" tabcounter="2" symbol="MSFT" exchange="NASDAQ"></div>
<div id="tabs-3" aria-labelledby="ui-id-3" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" tabcounter="3" symbol="GOOG" exchange="NASDAQ" style="display: none;"></div>
<div id="tabs-4" aria-labelledby="ui-id-4" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="true" aria-hidden="false" tabcounter="4" symbol="YHOO" exchange="NASDAQ" style="display: block;"></div>
爲了使它工作,我需要做的:
$("#tabs").tabs({active: index-1});
我不確定爲什麼需要「-1」。
我不知道爲什麼還是什麼我搞亂這裏...
這應該沒問題?由於var index = $(elem).index()不應該自動爲我提供正確的索引值(無論計數開始於何處)?? – user1357015