当前位置:   article > 正文

bootstrap4中实现标签页功能,标签页内容可以根据点击隐藏和显示_boottrap4 标签页功能

boottrap4 标签页功能

HTML代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="renderer" content="webkit">
    <meta name="force-rendering" content="webkit">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Page</title>
    <link rel="stylesheet" href="./assets/public/css/bootstrap.min.css">
</head>
<body>
    <ul class="nav nav-tabs" role="tablist" id="myTab">
        <li class="active">
            <a href="#tab-maosms" role="tab" data-toggle="tab">maosms</a>
        </li>
        <li>
            <a href="#tab-frpc" role="tab" data-toggle="tab">frpc</a>
        </li>
        <li>
            <a href="#tab-system" role="tab" data-toggle="tab">system</a>
        </li>
    </ul>
    <div class="tab-content" id="myContent">
        <div class="tab-pane active" id="tab-maosms">
            <div id="terminal-maosms"></div>
        </div>
        <div class="tab-pane" id="tab-frpc">
            <div id="terminal-frpc"></div>
        </div>
        <div class="tab-pane" id="tab-system">
            <div id="terminal-system"></div>
        </div>
    </div>
<script src="./assets/public/js/jquery.min.js"></script>
<script src="./assets/public/js/popper.min.js"></script>
<script src="./assets/public/js/bootstrap4.2.1.min.js"></script>
<script src="./assets/public/js/axios.js"></script>
<script src="./assets/public/js/qs.min.js"></script>
<script src="./assets/js/tail.js"></script>
</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

./assets/js/tail.js的内容:

$(function () {
    var thisTab = 'a[data-toggle="tab"]';
    $(thisTab).on('show.bs.tab', function (e) {
        if (e.relatedTarget) {
            var tabPaneNameOld = e.relatedTarget.getAttribute("href");
            $(tabPaneNameOld).attr("class", "tab-pane");
        }
        $(e.target).parent().siblings().each(function (number, obj) {
            $(obj).attr("class", "show");
        });
        $(e.target).parent().attr("class", "show active");
    });
});

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

效果:

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/69372
推荐阅读
相关标签
  

闽ICP备14008679号