zoukankan      html  css  js  c++  java
  • 为了不重复_table

    var Class = {   
          create: function() {   
            return function() {   
              this.initialize.apply(this, arguments);   
            }   
          }   
        }
    var table = Class.create();
    table.prototype = {
        initialize: function(a,b,c,d,e){
            if(document.getElementById(a) && document.getElementById(c)){
                this.b = document.getElementById(a).getElementsByTagName(b);
                this.d = document.getElementById(c).getElementsByTagName(d);
                this.e = e
                this.show();
                }
            },
        index: function(a,b){
            for(var i in b){
                if(a == b[i]){
                return i;
                }
            }
            },
        show: function(){
            var tli = this.b;
            var mli = this.d;
            var index = this.index;
            var cname = this.e;
            tli[0].className = cname;
            for(var z=0; z<mli.length; z++){
                mli[z].style.display = "none";
                }
            mli[0].style.display = "block";
            for(var i=0; i<tli.length; i++){
                tli[i].onclick = function(){
                    for(var y=0; y<tli.length; y++){
                        tli[y].className = "";
                        mli[y].style.display = "none";
                        }
                    this.className = cname;
                    var x = index(this,tli);
                    mli[x].style.display = "block";
                    }
                }
            }
        }
    new table("title","li","main","li","on");

  • 相关阅读:
    (01)Docker简介
    Gym-101242B:Branch Assignment(最短路,四边形不等式优化DP)
    2019牛客暑期多校训练营(第三场)G: Removing Stones(启发式分治)
    POJ
    高维前缀和
    HDU
    BZOJ
    HDU
    POJ
    Gym-100648B: Hie with the Pie(状态DP)
  • 原文地址:https://www.cnblogs.com/somesayss/p/2486865.html
Copyright © 2011-2022 走看看