I have the following script which gets the index of the selected tab:
http://jsfiddle.net/oshirowanen/eWncA/
Is it possible to get the id instead, if the li's had id's. If it is easier to get it from elsewhere, then that would also be fine, i.e. the related div tags, or somewhere else.
ID is an identifier that allows the tab component to be referenced by other components in the page.
var selectedTab = $("#TabList"). tabs(). data("selected. tabs");
jQuery UI just adds a class to the selected li. You could just pull the li with the selected class out like this:
var id = $("li.tab.ui-tabs-selected").attr("id");
If you wanted to get one of the unselected tabs you could do something like this:
var id = $("li.tab:not(.ui-tabs-selected)").first().attr("id");
Working example:
http://jsfiddle.net/UBs9m/2/
var id = $("li.tab:eq("+selected+")").attr('id');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With