首页 > Web开发 > 详细

JS 基于面向对象的 轮播图1

时间:2016-06-18 01:16:32      阅读:243      评论:0      收藏:0      [点我收藏+]

---恢复内容开始---

 1 ‘use strict‘
 2 function Tab(id){
 3     if(!id)return;
 4     this.oBox = document.getElementById(id);
 5     this.aBtn = this.oBox.getElementsByTagName(‘input‘);
 6     this.aDiv = this.oBox.getElementsByTagName(‘div‘);
 7     this.iNow = 0;
 8     this.init();
 9 }
10 Tab.prototype.init = function(){
11     var _this = this;
12     for(var i=0;i<this.aBtn.length;i++){
13         this.aBtn[i].index = i;
14         this.aBtn[i].onclick=function(){
15             _this.iNow = this.index;
16             _this.tab();
17         };
18     }
19 };
20 Tab.prototype.tab = function(){
21     for(var i=0;i<this.aBtn.length;i++){
22         this.aBtn[i].className=‘‘;
23         this.aDiv[i].className=‘‘;
24     }
25     this.aBtn[this.iNow].className=‘on‘;
26     this.aDiv[this.iNow].className=‘on‘;
27 };

  

 

JS 基于面向对象的 轮播图1

原文:http://www.cnblogs.com/zsongs/p/5595482.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!