原生js轮播效果demo
来源:互联网 发布:linux多线程机制 编辑:程序博客网 时间:2024/06/07 11:51
<!DOCTYPE html><html><head><title>demo</title><style>span{padding:5px 10px; background:blue;margin-bottom:5px;}.box{width:300px;height:100px;overflow:hidden;}.box div{width:300px;height:100px; display:none;}.box .block{display:block;}#status .active{background:#ccc;}</style><script>window.onload = function(){function BannerToggle(time, obj){var time = time;//循环时间var box = document.querySelector(obj);var count = 1;var timeId = null;var status = document.querySelectorAll('#status span');function autoPlay(){if(count <= 3){box.querySelector('.block').className = box.querySelector('.block').className.replace('block','');box.querySelectorAll('div')[count].className = 'block';document.querySelector('#status .active').className = document.querySelector('#status .active').className.replace('active','');status[count].className = 'active';count++;}else{count = 0;box.querySelector('.block').className = box.querySelector('.block').className.replace('block','');box.querySelectorAll('div')[count].className = 'block';document.querySelector('#status .active').className = document.querySelector('#status .active').className.replace('active','');status[count].className = 'active';count++;}}this.init = function(){timeID = setInterval(autoPlay,time);for(var i = 0; i < status.length; i++ ){(function(j){console.log(j);status[j].onmouseenter = function(){clearInterval(timeID);count = j;console.log(count);box.querySelector('.block').className = box.querySelector('.block').className.replace('block','');box.querySelectorAll('div')[count].className = 'block';document.querySelector('#status .active').className = document.querySelector('#status .active').className.replace('active','');status[count].className = 'active';}status[j].onmouseleave = function(){count++;timeID = setInterval(autoPlay,time);}})(i);}}this.init();}var a = new BannerToggle(3000, '.box');}</script></head><body><div style="padding:10px 0;" id="status"><span class="active">1</span><span>2</span><span>3</span><span>4</span></div><div class="box"><div style="background:red;" class="block"></div><div style="background:#ccc;"></div><div style="background:green;"></div><div style="background:yellow;"></div></div><div style="width:100px;height:100px;padding:100px;margin:100px;background:#000;"></body></html>
0 0
- 原生js轮播效果demo
- 原生javascript简单轮播效果demo
- 原生js实现轮播的小demo
- 原生js轮播
- JS原生实现图片轮播切换效果
- 原生js三种选项卡效果(轮播)
- 原生js轮播算法
- js原生图片轮播
- js原生图片轮播
- 原生js实现轮播
- 原生javascript实现图片轮播效果
- JS原生轮播(JS篇)
- 纯原生JS轮播图片
- 用原生JS写无缝轮播
- 原生JS-实现无限图片轮播
- 用原生js实现无缝轮播
- 原生Js实现图片轮播
- 图片轮播JS效果
- cscope doesn't work with symbolic link file
- 大话设计模式记录
- 杭电2072 杭电2073 单词数 无限的路
- 【Android】图形图像处理之”简单图片“
- 李开复:未来看好这五大领域!
- 原生js轮播效果demo
- js中根据后台返回结果动态创建表
- PAT (Advanced Level) 1124. Raffle for Weibo Followers (20) 解题报告
- 训练19-HTML 给标签增加圆角边框
- 带你熟悉SQLServer2016中的System-Versioned Temporal Table 版本由系统控制的临时表
- 杭电2056之Rectangles 杭电
- Another app is currently holding the yum lock; waiting for it to exit解决方法
- python虚拟环境virtualenv
- PAT (Advanced Level) 1125. Chain the Ropes (25) 解题报告