Bootstrap可切换标签

时间:2012-12-02 05:14:53

标签: html twitter-bootstrap

我是bootstrap的新手。我试图使用代码来制作带有可切换标签的页面。但是,我已多次检查我的代码,但我仍然无法在代码中找到问题。请问有人帮帮我吗?

<div class="row">

  <div class="tabbable">

    <ul class="nav nav-tabs" id="tabs" data-tabs="tabs">
      <li class="active"><a href="#having_a" data-toggle="tab">Having a</a></li>
      <li><a href="#having_b" data-toggle="tab">Having b</a></li>
      <li><a href="#having_c" data-toggle="tab">Having c</a></li>
    </ul>

  <!-- content of the tab -->
    <div class="tab-content" id="tab-content">

      <div class="tab-pane active" id="having_a">
        <p>a</p>
      </div>

      <div class="tab-pane" id="having_b">
        <p>b</p>
      </div>

      <div class="tab-pane" id="having_c">
        <p>c</p>
      </div>

    </div>

  </div>

  <script type="text/javascript">
     jQuery(document).ready(function ($) {$('#tabs').tab(); });
  </script>    

  </div>     

  <hr>

  <footer>
    <p>&copy;2012</p>
  </footer>

</div> <!-- /container -->

<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.js"></script>
<script src="js/bootstrap-transition.js"></script>
<script src="js/bootstrap-alert.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<script src="js/bootstrap-scrollspy.js"></script>
<script src="js/bootstrap-tab.js"></script>
<script src="js/bootstrap-tooltip.js"></script>
<script src="js/bootstrap-popover.js"></script>
<script src="js/bootstrap-button.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>

1 个答案:

答案 0 :(得分:1)

您没有在

中添加功能
  1. ID = “MYTAB”
  2. 插入$ .tab('show')
  3. 例如

       <ul class="nav nav-tabs id="myTab">
          <li class="active"><a href="#having_a" data-toggle="tab">Having a</a></li>
          <li><a href="#having_b" data-toggle="tab">Having b</a></li>
          <li><a href="#having_c" data-toggle="tab">Having c</a></li>
        </ul>
    
    <script>
      $(function () {
        $('#myTab').tab('show');
      })
    </script>
    

    http://twitter.github.com/bootstrap/javascript.html#tabs