html 书签不适用于 ul 标签面板

html bookmarks not working for ul tab panel

我想从外部页面打开一个隐藏的id书签 它不适合我

所以当我打开 link 例如:(page.php#translator2)

它只给出顶部的按钮,下面没有内容

请指教

<div class='profile_main_column column ' style='margin-top: 10px;'>
  <ul class='nav nav-tabs' role='tablist' id='profileTabs'>
    <li role='presentation'><a href='#translator1' aria-controls='translator1' role='tab' data-toggle='tab'>translator1_name </a></li>
    <li role='presentation'><a href='#translator2' aria-controls='translator2' role='tab' data-toggle='tab'>$translator2_name</a></li>
    <li role='presentation'><a href='#translator3' aria-controls='translator3' role='tab' data-toggle='tab'>$translator3_name</a></li>
  </ul>
  <div class='tab-content'>
    <div role='tabpanel' class='tab-pane ' id='translator1'>
      <div>
        <u><b>title1</b></u> body1
      </div>
    </div>
    <div role='tabpanel' class='tab-pane ' id='translator2'>
      <div>
        <u><b>title2</b></u> body2
      </div>
    </div>
    <div role='tabpanel' class='tab-pane ' id='translator3'>
      <div>
        <u><b>title3</b></u> body3
      </div>
    </div>
  </div>
</div>

尝试在 tab-pane 之后的第一个选项卡中添加 class="active",希望它能解决您的问题。谢谢

如果你想根据 hash 在 URL 中显示你的 tabs,你必须在 $(document).ready 方法中添加以下脚本。

var hash = window.location.hash;
if(hash != '') {
  $('.nav-tabs a[href="' + hash + '"]').tab('show');
}

var hash = window.location.hash;
if(hash != '') {
  $('.nav-tabs a[href="' + hash + '"]').tab('show');
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<div class='profile_main_column column ' style='margin-top: 10px;'>
  <ul class='nav nav-tabs' role='tablist' id='profileTabs'>
    <li role='presentation'><a href='#translator1' class="active" aria-controls='translator1' role='tab' data-toggle='tab'>translator1_name </a></li>
    <li role='presentation'><a href='#translator2' aria-controls='translator2' role='tab' data-toggle='tab'>$translator2_name</a></li>
    <li role='presentation'><a href='#translator3' aria-controls='translator3' role='tab' data-toggle='tab'>$translator3_name</a></li>
  </ul>
  <div class='tab-content'>
    <div role='tabpanel' class='tab-pane active' id='translator1'>
      <div>
        <u><b>title1</b></u> body1
      </div>
    </div>
    <div role='tabpanel' class='tab-pane ' id='translator2'>
      <div>
        <u><b>title2</b></u> body2
      </div>
    </div>
    <div role='tabpanel' class='tab-pane ' id='translator3'>
      <div>
        <u><b>title3</b></u> body3
      </div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>