zoukankan      html  css  js  c++  java
  • 原生js--分页(方法一)

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    .tab{
    400px;
    height: 600px;
    margin: 100px auto;
    }
    .tab-head{
    height: 100px;
    background-color: aquamarine;
    }
    .tab-head div{
    border: 1px solid red;
    48%;
    height: 100px;
    text-align: center;
    line-height: 100px;
    display: inline-block;
    color: brown;
    font-size: 20px;
    font-weight: bold;

    }
    .tab-head div.active{
    background: blueviolet;
    }
    .tab-body div{
    height: 500px;
    display: none;
    background: blueviolet;

    }
    .tab-body div.active{
    display: block;
    }
    </style>
    </head>
    <body>
    <div class="tab">
    <div class="tab-head">
    <div id="head1"class="active" onclick="tab(1)">首页</div>
    <div id="head2" onclick="tab(2)">菜单</div>
    </div>
    <div class="tab-body">
    <div id="body1" class="active">1111</div>
    <div id="body2">222</div>
    </div>
    </div>

    <script>
    // 封装函数
    function $(id){
    return document.getElementById(id);
    }
    function tab(num){
    for(var i = 1; i<=2;i++){
    //通过id选择元素 将它的class改变
    $('head'+i).className="";
    $('body'+i).className="";
    }
    //通过参数将它们连起来
    $('head'+num).className ='active';
    $('body'+num).className = 'active';
    }

    </script>
    </body>
    </html>

  • 相关阅读:
    异步与回调的设计哲学
    CTF之PHP黑魔法总结
    图片隐写分离
    phpMyadmin各版本漏洞
    python 多线程
    order by name 注入
    Python lambda
    Python os.popen() 方法
    你和大牛差了啥
    Error: failure: repodata/repomd.xml from fedora: [Errno 256] No more mirrors to try.
  • 原文地址:https://www.cnblogs.com/weixin2623670713/p/13801265.html
Copyright © 2011-2022 走看看