• 面向对象版选项卡


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    *{
    padding:0;
    margin:0;
    list-style: none;
    }
    #box1,#box2,#box3{
    500px;
    height:500px;
    border:1px solid red;
    }
    #box1 input,#box2 input,#box3 input{
    background: yellow;
    }
    #box1 .active,#box2 .active,#box3 .active{
    background: red;
    }
    #box1 div,#box2 div,#box3 div{
    300px;
    height:300px;
    background: red;
    font-size: 50px;
    text-align: center;
    line-height: 300px;
    display: none;
    }
    #box1 .show,#box2 .show,#box3 .show{
    display: block;
    }
    </style>
    </head>
    <body>
    <div id="box1">
    <input type="button" value="按钮1" class="active">
    <input type="button" value="按钮2">
    <input type="button" value="按钮3">
    <div class="show">1</div>
    <div>2</div>
    <div>3</div>
    </div>
    <div id="box2">
    <input type="button" value="按钮1" class="active">
    <input type="button" value="按钮2">
    <input type="button" value="按钮3">
    <input type="button" value="按钮4">
    <input type="button" value="按钮5">
    <div class="show">1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    </div>
    <div id="box3">
    <input type="button" value="按钮1" class="active">
    <input type="button" value="按钮2">
    <input type="button" value="按钮3">
    <input type="button" value="按钮4">
    <input type="button" value="按钮5">
    <input type="button" value="按钮6">
    <input type="button" value="按钮7">
    <div class="show">1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    <div>7</div>
    </div>
    <script>
    function tab(id) {
    var _this = this;
    this.oBox = document.getElementById(id);
    this.aBtn = this.oBox.getElementsByTagName('input');
    this.aBox = this.oBox.getElementsByTagName('div');
    for (var i=0; i<this.aBtn.length; i++) {
    this.aBtn[i].index = i;
    this.aBtn[i].onclick = function () {
    _this.fnClick(this)
    }
    }
    tab.prototype.fnClick = function (oBtn) {
    for (var i=0; i<this.aBtn.length; i++) {
    this.aBtn[i].className = '';
    this.aBox[i].className = '';
    }
    this.aBox[oBtn.index].className = 'show';
    oBtn.className = 'active';
    }
    }
    new tab('box1');
    new tab('box2');
    new tab('box3');
    </script>
    </body>
    </html>
  • 相关阅读:
    Django 之DRF删改查的API接口
    Django 之DRF原理操作
    通过密码、username、时间戳进行md5加密简单脚本
    Java 之GC常用命令
    ORM 之常用查询、字段类型、约束
    ORM 之单表查询案例
    Django session使用
    K8S 之yaml文件参数介绍1
    K8S 之使用Capabilities与限制网络带宽
    K8S 之容器生命周期钩子
  • 原文地址:https://www.cnblogs.com/qiudongjie/p/6602716.html
Copyright © 2020-2023  润新知