Get Index of Activated Tab

Eric J. picture Eric J. · Mar 12, 2013 · Viewed 10.6k times · Source

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?

Answer

Justin Bicknell picture Justin Bicknell · Mar 12, 2013

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

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

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