Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:21:43+00:00 2026-06-06T13:21:43+00:00

Using Twitter Bootstrap’s bootstrap-tab.js, I have: <ul class=tabnavcenter id=myTab> <li class=active><a href=#home data-toggle=tab>about</a></li> <li><a

  • 0

Using Twitter Bootstrap’s bootstrap-tab.js, I have:

<ul class="tabnavcenter" id="myTab">
   <li class="active"><a href="#home" data-toggle="tab">about</a></li>
   <li><a href="#tab2" data-toggle="tab">education</a></li>
   <li><a href="#tab3" data-toggle="tab">experience</a></li>
   <li><a href="#tab4" data-toggle="tab">verified skills</a></li>
   <li><a href="#tab5" data-toggle="tab"> video</a></li>
 </ul>

<div class="tab-content">
  <div class="tab-pane active" id="home">Content 1</div>
  <div class="tab-pane" id="profile">...</div>
  <div class="tab-pane" id="messages">...</div>
  <div class="tab-pane" id="settings">...</div>
</div>

How can I get it so if I put:

 <div class="tab-content">
   <div class="tab-pane active" id="home">Content 2</div>
 </div>

… two places in the profile (once above and once below a navbar) and with different content in each, it would work? As of now, the content appears, but once its clicked, it disappears. Can there be two “active” li’s at the same time?

Edit:

Since I’m using this in a Rails 3.2 App, I currently have the following in bootstrap-tab.js:

 $('#myTab a').click(function (e) {
   e.preventDefault();
  $(this).tab('show');
})


 $('#myTab a[href="#home"]').tab('show');
 $('#myTab a[href="#tab2"]').tab('show');
 $('#myTab a[href="#tab3"]').tab('show');
 $('#myTab a[href="#tab4"]').tab('show');
 $('#myTab a[href="#tab5"]').tab('show');
 $('#myTab a[href="#home2"]').tab('show');
 $('#myTab a[href="#tab22"]').tab('show');

and after putting the following in user_body.html.erb:

 <script type="text/javascript">
    $(function () {
       $('#myTab >li>a').on('click', function (e) {
        e.preventDefault();
        $(this).tab('show');
        //
        $(this.getAttribute('href') + '2').html($(this).html());
       });
   });

… I get the second content in the div after refreshing the page, no change when I click on the second tab, and then a change back to the name of the first ‘a’ when I click back on the first one.

It’s a mess.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:21:46+00:00Added an answer on June 6, 2026 at 1:21 pm

    Here is one solution without extra javascript, and compatible with the plugin API.

    The principle is to use 2 .tab-content and take advantage of the data-target selector attribute.

    HTML

    The first .tab-content contains your normal .tab-pane

    <div class="tab-content">
        <div class="tab-pane active" id="home">home</div>
        <div class="tab-pane home-tab">class home</div>
        <div class="tab-pane profile-tab">profile</div>
        <div class="tab-pane messages-tab">messages</div>
        <div class="tab-pane settings-tab">settings</div>
    </div>
    

    and the second .tab-content contains the extra .tab-panes that are optionnal – plus an empty one (#notab_else here)

    <div class="tab-content">
        <div class="tab-pane active" id="home_else">home_else</div>
        <div class="tab-pane home-tab">class home</div>
        <div class="tab-pane profile-tab messages-tab settings-tab" id="notab_else"></div>
    </div>
    

    Then you have your tabs with one extra attribute, data-target :

    <ul class="nav nav-tabs" id="myTab">
        <li class="active"><a href="#home" data-target="#home, #home_else">Home</a></li>
        <li class=""><a href="#home" data-target=".home-tab">Class Home</a></li>
        <li><a href="#profile" data-target=".profile-tab">Profile</a></li>
        <li><a href="#messages" data-target=".messages-tab">Messages</a></li>
        <li><a href="#settings" data-target=".settings-tab">Settings</a></li>
    </ul>
    

    This attribute data-target defines the .tab-pane(s) associated with it. The magic is that you can use #ids or .classes or any valid jQuery selector.

    JavaScript

    All you need to activate everything is the default code :

    $('#myTab a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
    });
    

    And you can also use your own actions to trigger the tabs as defined by the API.

    You do not need that if you keep the default behavior for tabs.

    $('#myTab a:first').tab('show');
    

    EXTRA

    • You can be free of any javascript if you set data-toggle="tab" to the a elements
    • There is a fade effect available if you add the fade class to the .tab-pane (and fade in for the .active one)

    DEMOS

    Here is the demo (jsfiddle) and the demo with extra (jsfiddle)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using Twitter Bootstrap, and I have a question about how to
I have been using the Twitter Bootstrap to build the base layout for a
I'm asking about using a Twitter Bootstrap modal window with a Rails form helper
I'm using twitter bootstrap . I have a div with 25 px padding. I
I'm using Twitter Bootstrap, and have a Google map. Images on the map, such
I am using Twitter Bootstrap and at one place I have nested fluid-grid in
I am using Twitter bootstrap modals To load data from a table. Here is
I have a modal created using Twitter Bootstrap. I want to open using javascript.
I am using twitter bootstrap but have a problem with the nav bar height
I am using Twitter bootstrap for Rails/SASS and have notice that it applies a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.