首页 > Web开发 > 详细

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

时间:2016-06-18 01:16:52      阅读:163      评论:0      收藏:0      [点我收藏+]
<script>

// 函数不能重名, --> 子函数
// is defined function --> 函数名是否写错了
function AutoTab(id) {
    Tab.apply(this, arguments);
    this.timer = null;
    this.inits();
    // this.autoPlay();
}

AutoTab.prototype = new Tab();
AutoTab.prototype.constructor = AutoTab;

// 初始化
AutoTab.prototype.inits = function () {
    this.play();
    this.over();
    this.out();
};

// 自动播放
AutoTab.prototype.play = function(){
    var _this = this;
    this.timer = setInterval(function(){
        _this.iNow++;
        if(_this.iNow==_this.aBtn.length){
            _this.iNow = 0;
        }
        _this.tab();
    },1000);
};
// 停止
AutoTab.prototype.stop = function () {
    clearInterval(this.timer);
};
// 鼠标经过
AutoTab.prototype.over = function () {
    var _this = this;
    this.oBox.onmouseover = function () {
        _this.stop();
    };
};
// 鼠标离开
AutoTab.prototype.out = function () {
    var _this = this;
    this.oBox.onmouseout = function () {
        _this.play();
    };
};

window.onload=function(){
    new Tab(‘tab1‘);
    new AutoTab(‘tab2‘);
};

</script>

  

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

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

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