当先锋百科网

首页 1 2 3 4 5 6 7

官网地址:https://v3.bootcss.com/

HTML+JS引入

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" target="_blank" rel="external nofollow"  rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>

1. 标签页

  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#home" target="_blank" rel="external nofollow"  aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
    <li role="presentation"><a href="#profile" target="_blank" rel="external nofollow"  aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
    <li role="presentation"><a href="#messages" target="_blank" rel="external nofollow"  aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
    <li role="presentation"><a href="#settings" target="_blank" rel="external nofollow"  aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
  </ul>

标签页中的内容

<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="home">HOME</div>
    <div role="tabpanel" class="tab-pane" id="profile">PROFILE</div>
    <div role="tabpanel" class="tab-pane" id="messages">MESSAGE</div>
    <div role="tabpanel" class="tab-pane" id="settings">SETTINGS</div>
  </div>

使用JS填充标签页中的内容

<script type="text/javascript">
  $(function () {
    $('#myTab a:first').tab('show');//初始化显示哪个tab
    $('#myTab a').click(function (e) {
      $('.tab-pane').empty()
      e.preventDefault();
      $(this).tab('show');
    })
  })
</script>