bootstrap 3 tabs not working properly

后端 未结 14 2636
情深已故
情深已故 2020-12-24 05:58

I almost copied the code from their website. The tab is initiated perfectly, and when I click on tabs, new panels are activated. However, the \"active\" class is not applied

相关标签:
14条回答
  • 2020-12-24 06:25

    My problem was that I sillily concluded bootstrap documentation is the latest one.
    If you are using Bootstrap 4, the necessary working tab markub is: http://v4-alpha.getbootstrap.com/components/navs/#javascript-behavior

    <ul>
      <li class="nav-item"><a class="active" href="#a" data-toggle="tab">a</a></li>
      <li class="nav-item"><a                href="#b" data-toggle="tab">b</a></li>
    </ul>
    
    <div class="tab-content">
      <div class="tab-pane active" id="a">a</div>
      <div class="tab-pane"        id="b">b</div>
    </div>
    
    0 讨论(0)
  • 2020-12-24 06:25

    In my case (dynamically generating the sections): the issue was a missing "#" in href="#...".

    0 讨论(0)
  • 2020-12-24 06:29

    My problem was with extra </div> tag inside the first tab.

    0 讨论(0)
  • 2020-12-24 06:34

    When I moved the following lines from the head section to the end of the body section it worked.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    0 讨论(0)
  • 2020-12-24 06:35

    Use this for your code

    <ul class="nav nav-tabs" style="margin-top:10em;">
      <li class="active" data-toggle="tab"><a href="#">Assign</a></li>
    <li data-toggle="tab"><a href="#">Two</a></li>
    <li data-toggle="tab"><a href="#">Three</a></li>
    

    0 讨论(0)
  • 2020-12-24 06:36

    In my case, I have two elements with the same id. I could not notice the cause of problem for a long time, because the first such element was hidden.

    0 讨论(0)
提交回复
热议问题