Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI tabs. How to select a tab based on its id not based on index

I have two tabs and configured usign jQuery UI.

ul  class="tabs"   li  tabone   li tabtwo ul 

dynamically from C# code behind I will hide or select some tab let say tabtwo and the other tab has to be hidden or not shown. I can do this in JavaScript using .tabs({selected:1}); and .tabs(disable:0). but I don't want to use the tab indexes to do so.

Is there any alternate to select tabs based on their name/id?

like image 504
user695663 Avatar asked May 06 '11 14:05

user695663


People also ask

How do I know which tab is selected in jquery?

click('tabsselect', function (event, ui) { var selectedTab = $("#tabs"). tabs('option', 'active'); $("#hidLastTab"). val(selectedTab); });


1 Answers

Accepted answer didn't work for me either, however I found solution in a similar thread: Switch to selected tab by name in Jquery-UI Tabs

var index = $('#tabs a[href="#simple-tab-2"]').parent().index(); $('#tabs').tabs('select', index); 

With jQuery UI >= 1.9:

var index = $('#tabs a[href="#simple-tab-2"]').parent().index(); $("#tabs").tabs("option", "active", index); 
like image 164
stankovski Avatar answered Sep 25 '22 08:09

stankovski