JS面向对象实例

来源:luqidong 发布时间:2014-06-11 20:27:43 点击数:

如图

78OA办公系统

代码如下:

window.onload=function ()
{
new TabSwitch('div1');
};
 
function TabSwitch(id)
{
var _this=this;
var oDiv=document.getElementById(id);
 
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
 
for(var i=0;i
{
this.aBtn[i].index=i;
this.aBtn[i].onclick=function ()
{
_this.fnClick(this);
};
}
};
 
TabSwitch.prototype.fnClick=function (oBtn)
{
//alert(this);
for(var i=0;i
{
this.aBtn[i].className=''
this.aDiv[i].style.display='none';
}
oBtn.className='active';
this.aDiv[oBtn.index].style.display='block';
}

本文78oa系统编辑所撰,如若转载请注明出处。