2

In jquery UI, using their newest version, I can't get the ID of the selected tab anymore. I tried ui.index from jQuery UI Tabs Get Currently Selected Tab Index, but it gives me undefined.

Does anyone know the way to do this now?

$( "#tabs" ).bind( "tabsactivate", function(event, ui) { 
    alert(ui.index);
});

In this code, I get the alert every time I select a new tab, but its says undefined.

Thanks

Community
  • 1
  • 1
omega
  • 40,311
  • 81
  • 251
  • 474

1 Answers1

15

You need to use it this way. ui does not have any property called index

alert(ui.newTab.index());

Demo

  1. Get the index of currently selected tab: ui.newTab.index()
  2. Get the index of last selected tab: ui.oldTab.index()

ui.newTab will return you the jquery object representing the element and you can invoke the index() method on it to get the index.

PSL
  • 123,204
  • 21
  • 253
  • 243