You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现4步教程定时自动切换active类与对应图片并循环的功能

你可以直接用下方的JavaScript代码替换原有JS部分,即可实现每隔3秒自动切换步骤、第4步结束后自动回到第1步循环的效果,你也可以自行修改代码里的切换间隔时长:

// 合并原有点击逻辑,减少重复绑定
jQuery(".tutorial-point").click(function (e) {
    e.preventDefault();
    jQuery(".tutorial-point").removeClass("active-tuto");
    jQuery(this).addClass("active-tuto");
    const imgSRC = jQuery(this).data('src');
    jQuery('#imageFlowchart').html(`<img src="${imgSRC}" alt="" />`);
});

// 自动轮播逻辑
const stepList = jQuery(".tutorial-point");
let currentStep = 0;
const switchInterval = 3000; // 切换间隔单位为毫秒,3000对应3秒,可按需调整

setInterval(() => {
    // 索引取余实现循环效果
    currentStep = (currentStep + 1) % stepList.length;
    // 直接触发对应步骤的点击事件,复用已有逻辑无需重复开发
    stepList.eq(currentStep).click();
}, switchInterval);

内容的提问来源于stack exchange,提问作者Adzidue

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 08:54:04