问答详情
源自:3-13 编程练习

我感觉代码都对,科室为啥第二项的内容显示不出来

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Hello World</title>

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>

</head>


<body>

    <div>

     <ul class="nav nav-tabs" id="mytab">

      <li role="presentation" ><a href="#tab-1">第一项</a></li>

      <li role="presentation"><a href="#tab-2">第二项</a></li>

      <li role="presentation"><a href="#tab-3">第三项</a></li>

      <li role="presentation"><a href="#tab-4">第四项</a></li>

     </ul>

     <div>

         <div id="tab-1"></div>

         <div id="tab-2">慕课网是做什么的</div>

         <div id="tab-3"></div>

         <div id="tab-4"></div>

     </div>

    </div>




    <script src="/ http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

    <script>

            $(document).ready(function(){

$('#mytab a[href="#tab-2"]').tab('show') 

});

    </script>


</body>

</html>


提问者:慕粉4495554 2016-07-27 16:52

个回答

  • 小小奋斗Nice
    2016-07-28 01:07:18
    已采纳

    你的HTML代码写的不对,参考官方给的写法:

    http://v3.bootcss.com/javascript/#tabs-examples

    <div>


      <!-- Nav tabs -->

      <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>

        <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>


      <!-- Tab panes -->

      <div class="tab-content">

        <div role="tabpanel" class="tab-pane active" id="home">...</div>

        <div role="tabpanel" class="tab-pane" id="profile">...</div>

        <div role="tabpanel" class="tab-pane" id="messages">...</div>

        <div role="tabpanel" class="tab-pane" id="settings">...</div>

      </div>


    </div>