本文实例讲解了最简单的面向对象选项卡实现方法,分享给大家供大家参考,具体内容如下
效果图:
1、功能说明
3、css重点代码说明
4、js代码说明
for(var i = 0; i < this.count; i++){
//设置索引
this.aCon[i].index = i;
//给按钮添加事件
this.aCon[i].onclick = function(){
_this.cur = this.index;
_this.switch();
}
}
}
Tab.prototype.switch = function(){
//去掉所有
for(var i = 0; i < this.count; i++){
this.aIn[i].className = 'in';
this.aCon[i].className = 'con';
}
//显示当前
this.aIn[this.cur].className = 'in_active';
this.aCon[this.cur].className = 'con_active';
}
//获取选项卡元素
var oBox = document.getElementById('Box');
//构造选项卡对象
var tab1 = new Tab(oBox);
希望本文所述对大家学习javascript面向对象有所帮助。
原文地址:https://www.jb51.cc/js/50763.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。