twitter-bootstrap 隐藏 jquery UI 引导选项卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14603480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:13:54  来源:igfitidea点击:

Hide jquery UI bootstrap tab

jquerytwitter-bootstrap

提问by DevelopmentIsMyPassion

Is there any way to hide the Jquery UI bootstrap tab I have written code below to show the particular tab

有什么方法可以隐藏 Jquery UI 引导程序选项卡我在下面编写了代码来显示特定选项卡

 $('#myTab a:last').tab('show')

So i tried using below code to hide tab but it gives error that it has no method hide

所以我尝试使用下面的代码来隐藏选项卡,但它给出了没有方法隐藏的错误

 $('#myTab a:last').tab('hide')

I have declared tabs in following way in my html

我在我的 html 中以下列方式声明了标签

 <ul class="nav nav-tabs" id="myTab">
        <li><a href="#product" data-toggle="tab">Company</a></li>
        <li><a href="#version" data-toggle="tab">Employee</a></li>
  </ul>

采纳答案by Mandeep Jain

Have you tried $('#myTab a:last').hide()or $('#myTab a:first').hide()?

您是否尝试过$('#myTab a:last').hide()$('#myTab a:first').hide()

回答by Igor

Alternatively, you could simply remove the activeclass from the elements instead:

或者,您可以简单地active从元素中删除该类:

$('.nav-tabs li.active').removeClass('active');
$('.tab-content div.active').removeClass('active');

This way you won't have any hidden elements that are still marked as active, which may interfere with other JS or CSS.

这样你就不会有任何隐藏的元素仍然标记为active,这可能会干扰其他 JS 或 CSS。

回答by Prateek Mittal

There is no need to specially hide tab, you can just show the tab that you want and the other tab would automatically be hidden. You can use :

不需要特别隐藏标签,你可以只显示你想要的标签,另一个标签会自动隐藏。您可以使用 :

$("a[href='#tabToBeShown']").tab("show");