news 2026/7/28 18:23:49

轮播图

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
轮播图

//轮播图 function animate (offset) { if (offset == 0) { return; } animated = true; var time = 300; var inteval = 10; var speed = offset/(time/inteval); var left = parseInt(list.style.left) + offset; var go = function (){ if ( (speed > 0 && parseInt(list.style.left) < left) || (speed < 0 && parseInt(list.style.left) > left)) { list.style.left = parseInt(list.style.left) + speed + 'px'; setTimeout(go, inteval); } else { //无限轮播 list.style.left = left + 'px'; if(left>-200){ list.style.left = -600 * len + 'px'; } if(left<(-600 * len)) { list.style.left = '-600px'; } animated = false; } } go(); } function showButton() { //上移显示左右箭头 for (var i = 0; i < buttons.length ; i++) { if( buttons[i].className == 'on'){ buttons[i].className = ''; break; } } buttons[index - 1].className = 'on'; } function play() { //自动播放 timer = setTimeout(function () { next.onclick(); play(); }, interval); } function stop() { //鼠标上移自动暂停 clearTimeout(timer); } next.onclick = function () { if (animated) { return; } if (index == 5) { index = 1; } else { index += 1; } animate(-600); showButton(); } prev.onclick = function () { //点击小圆点跳转到相应图片 if (animated) { return; } if (index == 1) { index = 5; } else { index -= 1; } animate(600); showButton(); } for (var i = 0; i < buttons.length; i++) { buttons[i].onclick = function () { if (animated) { return; } if(this.className == 'on') { return; } var myIndex = parseInt(this.getAttribute('index')); var offset = -600 * (myIndex - index); animate(offset); index = myIndex; showButton(); } } container.onmouseover = stop; container.onmouseout = play; play();
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/28 18:18:28

2026上海B端抖音运营公司选型指南:6家实测服务商盘点与避坑策略

72%的制造业企业短视频投入打水漂&#xff0c;90%代运营团队不懂工业采购逻辑——这篇耗时1个月实地调研的深度指南&#xff0c;帮长三角工厂老板避开“泛流量陷阱”-5。一、写在前面&#xff1a;2026年&#xff0c;你的抖音预算还在打水漂吗&#xff1f;“投了30万&#xff0c…

作者头像 李华
网站建设 2026/7/28 18:18:09

Python学习笔记(四):模块和列表

1.模块初识 - sys模块 打印环境变量&#xff1a;print(sys.path) 打印的结果为&#xff1a; [‘C:\Users\Phm\PycharmProjects\s14\day1’, ‘C:\Users\Phm\PycharmProjects\s14’, ‘C:\Users\Phm\AppData\Local\Programs\Python\Python37-32\python37.zip’, ‘C:\Users\Phm\…

作者头像 李华
网站建设 2026/7/28 18:16:20

Wordpress升级注意事项

Wordpress升级注意事项,用php7.2环境&#xff0c;一些方法和常量&#xff0c;要用单引号.不然会报错.

作者头像 李华
网站建设 2026/7/28 18:15:09

智能手表美国FCCID证书办理流程

智能手表带蓝牙/Wi-Fi/GPS/eSIM 等无线功能,去美国必须做 FCC ID(Certification),由 TCB 审核发证,不能只用 SDoC 代替。纯无无线发射的电子表才走 SDoC。 一、先定标准组合(智能手表常见) FCC Part 15B:无意辐射(EMC 传导/辐射骚扰) FCC Part 15C(15.247):蓝牙…

作者头像 李华