Bootstrap3--日常练手--实现面板折叠里面嵌入表格

大家好~ 珊妹这不是转了前端吗,前端插件真是数不胜数呢,所以珊妹打算以后会在闲暇时间来利用常用的插件来写一些大家平时可能会用到的例子来供大家参考,代码一定不是最优的,但尽可能是可用的,所以有幸遇到大神,还望多多提点一二~

下面我们来说今天的功能,利用bootstrap插件完成面板折叠嵌入表格:

首先下载bootstrap,这都不用说了,珊妹这里下载的是bootstrap3版本,下载链接:https://v3.bootcss.com/

大家还要下载个jquery.min.js文件,可以去官网下载;

然后解压后在当前目录新建一个html文件,把下面代码粘进去保存后双击文件就可看到结果:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

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

    <title>Document</title>

    <link rel="stylesheet" href="./bootstrap-3.3.7-dist/css/bootstrap.min.css">

    <script src="./jquery.min.js"></script>

    <script src="./bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <style>

        .panel-heading{

            cursor: pointer;

        }

    </style>

</head>

<body>

    <div class="panel panel-default">

        <!-- Default panel contents -->

        <div class="panel-heading" id="fold" data-toggle="collapse" data-target="#table">

            <span class="glyphicon glyphicon-triangle-right"></span>

            人员名单</div>     

        <!-- Table -->

        <div class="collapse" id="table">

            <table class="table">

                <tr>

                    <th>姓名</th>

                    <th>年龄</th>

                    <th>性别</th>

                </tr>

                <tr>

                    <td>珊珊美眉</td>

                    <td>18</td>

                    <td>女</td>

                </tr>

            </table>

        </div>

      </div>

<script>

$("#fold").click(function(){

    if($(this).find("span").hasClass("glyphicon-triangle-right")){

        $(this).find("span").removeClass("glyphicon-triangle-right");

        $(this).find("span").addClass("glyphicon-triangle-bottom");

    }else{

        $(this).find("span").removeClass("glyphicon-triangle-bottom");

        $(this).find("span").addClass("glyphicon-triangle-right");

    }

})

</script>

</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值