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

 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 };