0
votes

I have two different tabs set with bootstrap.

First tab set has a default active class and the second one has no active class at all. But when I go to second tab set it should hide the first tab set content as well. And should toggle accordingly.

<div id="first_tab_set">
  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
  </ul>
  <div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="home">...</div>
    <div role="tabpanel" class="tab-pane" id="profile">...</div>
  </div>
</div>


<div id="second_tab_set">
  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
    <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
  </ul>
  <div class="tab-content">
    <div role="tabpanel" class="tab-pane" id="messages">...</div>
    <div role="tabpanel" class="tab-pane" id="settings">...</div>
  </div>
</div>

How do I achieve this funciton from bootstrap ?

1
I'm assuming the "tabbing" functionality is not working (eg, showing-hiding content?) Can you please update your question with a more explicit description of the problem? Here is an example of a working bootstrap tabs component. Is this what you are looking for? Please provide any javascript you've written as well. - wahwahwah
In my code there are two tabs set. and the first tabset has home which is active. but it should hide when I click on second tab set. - Santosh
Please update your question with the relevant statement of the problem as well as the jQuery / javascript that you are working with. - wahwahwah

1 Answers

0
votes

I found the soluiton.

  $(".first_tab_set").click(function(){
    if($('.second_tab_set .tab-pane').hasClass("active")) {
    $(".second_tab_set").find(".active").removeClass("active");
  }
})
$(".second_tab_set").click(function(){
   if($('.first_tab_set .tab-pane').hasClass("active")) {
   $(".first_tab_set").find(".active").removeClass("active");
  }
})