Get Index of Activated Tab

北慕城南 提交于 2019-12-12 10:30:00

问题


I'm upgrading code from jQuery UI 1.8 to 1.10.

Under 1.8, the event triggered when the tab changes was select, and I could access the index of the tab being selected through ui.index.

Under 1.10, the event triggered when the tab changes is activate. However, I cannot find anything in the event parameter ui that tells me the index of the newly activated tab.

How can I discover that index?


回答1:


You could use the following approach http://jsfiddle.net/9ChL5/1/:

$("#tabs").tabs({
    activate: function (event, ui) {

        console.log(ui.newTab.index());
    }
});



回答2:


The UI object is still here but seems to hold directly the jQuery objects of oldTab, newTab, oldPanel, newPanel, so you don't need the index to find the object you want to use.

See http://api.jqueryui.com/tabs/#event-activate

ui Type: Object

- newTab
Type: jQuery
The tab that was just activated.
- oldTab
Type: jQuery
The tab that was just deactivated.
- newPanel
Type: jQuery
The panel that was just activated.
- oldPanel
Type: jQuery
The panel that was just deactivated.


来源:https://stackoverflow.com/questions/15367234/get-index-of-activated-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!