当前位置: 首页 > 图文教程 > 网络编程 > Javascript > javascript 通用滑动门tab类

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 javascript 通用滑动门tab类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 196 ::
收藏到网摘: n/a

滑动门JS并封装成类
点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]

源代码:
复制代码 代码如下:

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";
}
}
},
$ : function(oid){
if(typeof(oid) == "string")
return document.getElementById(oid);
return oid;
}
}

使用方法:
1.把以上代码引进你的页面
复制代码 代码如下:

<script type="text/javascript" src="scrollDoor.js"></script>

2.在页面的"<body>"标签前加入以下代码:
复制代码 代码如下:

<script type="text/javascript">
var SDmodel = new scrollDoor();
SDmodel.sd([菜单id数组],[显示层id数组],"菜单触发类","菜单关闭类");
SDmodel.sd([菜单id数组2],[显示层id数组2],"菜单触发类","菜单关闭类");
SDmodel.sd([菜单id数组3],[显示层id数组3],"菜单触发类","菜单关闭类");
</script>

其中sd方法中的参数为:
参数一 [菜单id数组]:滑动门菜单的id
参数二 [内容id数组]:显示和隐藏滑动内容层的id
参数三 "菜单触发类":鼠标经过滑动门菜单的类
参数四 "菜单关闭类":鼠标滑出滑动门菜单的类
3.页面中有几个滑动门就调用几次sd函数,只需改变sd调用的参数,如以上代码上所展示.