zoukankan      html  css  js  c++  java
  • 面向对象版选项卡

    <!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>
  • 相关阅读:
    局域网内其他机器访问本机80网站失败记录
    百度经纬度获取
    Win10安装安卓ADB驱动
    SQL Server 查看数据库是否存在阻塞
    IP地址接口小结
    雄冠条码PV系统-2016-05-17-收获
    slf4j MDC使用
    Java NIO之通道
    Java NIO之缓冲区
    记一次ThreadPoolExecutor面试
  • 原文地址:https://www.cnblogs.com/qiudongjie/p/6602716.html
Copyright © 2011-2022 走看看