9

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

 $('#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

 <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>
2
  • do you want only last tab to be hidden, just try to use hide() and show() methods instead.. Commented Jan 30, 2013 at 12:02
  • how to do it? Please explain. I want first tab to be closed Commented Jan 30, 2013 at 12:08

3 Answers 3

9

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

Sign up to request clarification or add additional context in comments.

2 Comments

Yes worked. Thanks a lot. Dont know why its not given in documentation on the website.
because it is not a part of bootstrap. I am simply using jquery methods to hide and show dom elements :)
8

Alternatively, you could simply remove the active class from the elements instead:

$('.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.

1 Comment

I us"ed" the hide fonction but when there are uls inside uls, your answer is veeery handy and elegant, thanks a lot cuz it really helped me
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.