js滑动门及对像的使用

function scrollDoor() { }
      scrollDoor.prototype = {
          sd: function (menus, divs, openClass, closeClass) {
              var _this = this;
              if (menus.length != divs.length) {
                  alert("菜单层数量和内容层数量不一样!");
                  return false;
              }
              for (var i = 0; i < menus.length; i++) {
                  _this.$(menus[i]).value = i;
                  _this.$(menus[i]).onmouseover = function () {

                      for (var j = 0; j < menus.length; j++) {
                          _this.$(menus[j]).className = closeClass;
                          _this.$(divs[j]).style.display = "none";
                      }
                      _this.$(menus[this.value]).className = openClass;
                      _this.$(divs[this.value]).style.display = "block";
                  }
              }
          },
          def: function (menus, divs, openClass, closeClass, menu, divshow) {
              var _this = this;
              for (var j = 0; j < menus.length; j++) {
                  _this.$(menus[j]).className = closeClass;
                  _this.$(divs[j]).style.display = "none";
              }
              _this.$(menu).className = openClass;
              _this.$(divshow).style.display = "block";
          },
          $: function (oid) {
              if (typeof (oid) == "string")
                  return document.getElementById(oid);
              return oid;
          }
      }

使用
 var SDmodel = new scrollDoor(); 
 SDmodel.sd(["d1","d2"],["c1","c2"],"li_up","");

案例
http://esf.sh.soufun.com/agent/agtagent/27686210.htm

转载于:https://www.cnblogs.com/zhangji/p/3586010.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值