JS 基于面向对象的 轮播图2
2016-06-18 00:17
543 查看
<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>
相关文章推荐
- 又被事件冒泡坑了一把,这次要彻底弄懂浏览器的事件流
- HTML特殊字符的html、js、css写法汇总
- js 优秀资源
- JS完美运动框架
- 7个常见Javascript框架介绍
- js委托事件-addEventListeners(冒泡方向)
- JS解析Json数据格式
- JS链式运动
- javascript 常用方法
- Javascript 面向对象编程
- 跳出多重循环 JS
- JavaScript初探
- 引用外部script文件是存放的位置
- json格式生成xml文件
- JavaScript:replace全部替换字符串
- 浏览器解析script标签遇到的问题
- JSP标准动作
- json格式数据转换为xml格式
- ajax原生js写法
- js变量数据类型分类