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 div{
    height: 100px;
    49%;
    background: aqua;
    display: inline-block;
    text-align: center;
    line-height: 100px;
    }
    .tab-head div.active{
    background: blue;
    }
    .tab-body div{
    height: 500px;
    background: blueviolet;
    display: none;
    }
    .tab-body div.active{
    display:block;
    }
    </style>
    </head>
    <body>
    <div class="tab">
    <div class="tab-head">
    <div class="head active"onclick="tab(0)">首页</div>
    <div class="head" onclick="tab(1)">菜单</div>
    </div>
    <div class="tab-body">
    <div class="body active">1111</div>
    <div class="body">2222</div>
    </div>
    </div>
    <script type="text/javascript">
    //方法:用class选择器选择出来 改变class值
    var head = document.getElementsByClassName('head');
    var body = document.getElementsByClassName('body');
    function tab(num){
    for(var i=0;i<=1;i++){
    head[i].className='head';
    body[i].className='body';
    }
    head[num].className='head active';
    body[num].className='body active';
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    《我与我的父辈》影评
    如何进行时间规划?
    内向者相关
    修己 0815
    loj 3102
    StringSequences
    解方程
    problem B
    uoj424 count
    fft相关的复习
  • 原文地址:https://www.cnblogs.com/weixin2623670713/p/13801279.html
Copyright © 2011-2022 走看看