tab切换,滑动门

本文介绍了一个使用jQuery实现的菜单切换效果示例。当鼠标悬停在不同菜单项上时,对应的展示区域会显示相关内容,同时隐藏其他内容。该示例通过自定义函数实现了菜单与内容之间的联动,并展示了如何利用jQuery简化DOM操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  <SCRIPT type=text/javascript>
  jQuery(document).ready(function () {
          changediv(["#ha1","#ha2"],["#hw1","#hw2"],"one")
    })    
      
  function changediv(menus,divs,opclass){
      if(menus.length != divs.length){
          alert("菜单个数与内容痛");
          return false;
          }
    for(var i=0; i<menus.length;i++){
        $(menus[i]).mouseover(function(){
              //alert("你搞错没有啊");
            // $(this).addClass(opclass).siblings().removeClass("one")
             for(var j=0; j<menus.length; j++){
                 $(menus[j]).removeClass(opclass);
                 $(divs[j]).css("display","none");
                 }
            //$(this).addClass(opclass);    
            $(this).addClass(opclass)    
            $(divs[$(this).index()]).css("display","block");
            })
        
        }      
      
      }
</SCRIPT>

 

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]).鼠标over事件[请自行修改] = 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";                
            }
        }
        },
    $ : function(oid){
        if(typeof(oid) == "string")
        return document.getElementById(oid);
        return oid;
    }
}

 

 jQuery(document).ready(function () {

var SDmodel = new scrollDoor();

SDmodel.sd(["an1", "an2","an3","an4","an5","an6"],["adr1", "adr2", "adr3","adr4","adr5","adr6"],"one");


    })

转载于:https://www.cnblogs.com/xqschool/p/6033156.html

body{ color: #000; font-family: "宋体", arial; font-size: 12px; background: #fff; text-align: center; margin: 0; } .nTab{ float: left; width: 240px; margin: 0 auto; border-bottom:1px #C7C7CD solid; background:#d5d5d5; background-position:left; background-repeat:repeat-y; margin-bottom:2px; } .nTab .TabTitle{ clear: both; height: 26px; overflow: hidden; } .nTab .TabTitle ul{ margin:0; padding:0; } .nTab .TabTitle li{ float: left; width: 60px; cursor: pointer; padding-top: 6px; padding-right: 0px; padding-left: 0px; padding-bottom: 7px; list-style-type: none; } .nTab .TabTitle .active{ background:url(images/finance_nc_080124_ws_001.gif) left -25px no-repeat;border-left:1px #C7C7CD solid;border-top:1px #C7C7CD solid;border-bottom:1px #fff solid;} .nTab .TabTitle .normal{ background:url(images/finance_nc_080124_ws_001.gif);border-top:1px #C7C7CD solid;border-bottom:1px #C7C7CD solid;} .nTab .TabContent{ width:auto;background:#fff; margin: 0px auto; padding:10px 0 0 0; border-right:1px #C7C7CD solid;border-left:1px #C7C7CD solid; } .none {display:none;} function nTabs(thisObj,Num){ if(thisObj.className == "active")return; var tabObj = thisObj.parentNode.id; var tabList = document.getElementById(tabObj).getElementsByTagName("li"); for(i=0; i <tabList.length; i++) { if (i == Num) { thisObj.className = "active"; document.getElementById(tabObj+"_Content"+i).style.display = "block"; }else{ tabList[i].className = "normal"; document.getElementById(tabObj+"_Content"+i).style.display = "none"; } } } 预拔电杆 预等电杆 普拔电杆 部预电杆 欢迎访问:阿里西西WEB开发 计源论坛 计源论坛 计源论坛22 计源论坛33
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值