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

前端 未结 14 2211
刺人心
刺人心 2020-12-25 11:07

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

14条回答
  •  悲哀的现实
    2020-12-25 11:47

    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);
    

提交回复
热议问题