Bart
Bart

Reputation: 4920

how do i check which tabs is active using jquery tabs?

how do i check which tabs is active using jquery tabs?

Upvotes: 8

Views: 19915

Answers (6)

kalpesh patil
kalpesh patil

Reputation: 81

var selectedTabIndex = 0;
jQuery("#tabContainer").tabs({
 select: function(event, ui) { 
  selectedTabIndex = ui.index; 
 }
});

You can use selectedTabIndex in your app

Upvotes: 0

Paweł Olesiejuk
Paweł Olesiejuk

Reputation: 11

I'm using something like this:

$tabContainer.tabs({
    activate: function (event, ui) {
        if (ui.newPanel.is("#TabId")) {
            // do sth here
        }
    }
});

Upvotes: 1

Chris Porter
Chris Porter

Reputation: 3687

I needed to get the active tab during the activate event. I was able to do this using the option active call.

$('#tabs').tabs({
    activate: function (event, ui) {
        var activeTabId = $(this).tabs('option', 'active');
    }
});

Upvotes: 2

Bartek
Bartek

Reputation: 1

var index = $("#tabs").tabs('option', 'selected');

Upvotes: 0

kbvishnu
kbvishnu

Reputation: 15630

Please try with Index

 function getIndex(){
     return $("ul li.ui-state-active").index();
    }

It will returns the index of selected li or tab.

Upvotes: 12

sk747
sk747

Reputation: 31

Not too sure about this but I think jQuery dynamically assigns a class of 'ui-state-active'

Upvotes: 1

Related Questions