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

前端 未结 14 2195
刺人心
刺人心 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:40

    I did it like this

    if (document.location.hash != '') {
       //get the index from URL hash
       var tabSelect = document.location.hash.substr(1, document.location.hash.length);
       console.log("tabSelect: " + tabSelect);
       if (tabSelect == 'discount')
       { 
           var index = $('#myTab a[href="#discount"]').parent().index();
           $("#tabs").tabs("option", "active", index);
           $($('#myTab a[href="#discount"]')).tab('show');
       }
    }
    

提交回复
热议问题