时间:2021-05-26
本文实例讲述了JS使用面向对象技术实现的tab选项卡效果。分享给大家供大家参考,具体如下:
运行效果图如下:
代码如下:
html:
<ul class="scrollUl"> <li id="m01" class="sd01" value="0"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >新服排期</a></li> <li id="m02" class="sd02" value="1"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >官方公告</a></li></ul><div id="c01" style="display: block;"> <ul> <li class="ml10 mt10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="最三国“群雄逐鹿”震撼开启 敬请期待." class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最三国“群雄逐鹿”震撼开启 ...</a></span><span class="hui9">09-28</span></li> </ul></div><div class="hidden" id="c02" style="display: none;"> <ul> <li class="ml10 mt10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> <li class="ml10"><span class="fu"><a title="《绝地战争》9月8日维护公告" class="hei" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《绝地战争》9月8日维护公告</a></span><span class="hui9">09-28</span></li> </ul></div>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(){ //1.先关闭所有的导航和内容: for(var j = 0 ; j < menus.length ; j++) { _this.$(menus[j]).className = closeClass; _this.$(divs[j]).style.display = "none"; } //2.打开当前的导航和内容: //_this.$(menus[this.value]).className = openClass; this.className = openClass; _this.$(divs[this.value]).style.display = "block"; } } }, $ : function(oid){ if(typeof(oid) == "string") return document.getElementById(oid); return oid; }}window.onload = function(){ var SDmodel = new scrollDoor(); SDmodel.sd(["m01","m02"],["c01","c02"],"sd01","sd02"); //SDmodel.sd(["m001","m002"],["c001","c002"],"sd01","sd02");}更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《javascript面向对象入门教程》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结》
希望本文所述对大家JavaScript程序设计有所帮助。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了js基于面向对象实现网页TAB选项卡菜单效果代码。分享给大家供大家参考。具体如下:这是一款自动的网页TAB,基于面向对象的选项卡菜单,由于时间关系
本文实例讲述了JS面向对象编程实现的Tab选项卡。分享给大家供大家参考,具体如下:Tab选项卡案例下面是一个简单面向过程的Tab选项卡。#tabBoxinput
本文实例讲述了JS基于myFocus库实现各种功能的tab选项卡切换效果。分享给大家供大家参考。具体如下:这里介绍使用myFocus-tab实现各种功能的选项卡
本文实例讲述了JS实现的不规则TAB选项卡效果代码。分享给大家供大家参考。具体如下:这是一款采用菱形的选项卡效果,一改选项卡中规中矩的风格,效果非常不错,奉献给
本文实例讲述了JS实现黑色风格的网页TAB选项卡效果代码。分享给大家供大家参考。具体如下:这是一款网页TAB选项卡JS代码,黑色超酷的风格,看了后你会喜欢的,很