$(document).ready(function() { var rotatenum=4; $("#steps-menu[name='pc'] a").click(function(event) { // replaces main content event.preventdefault(); $(this).parent().addclass("is-active"); $(this).parent().siblings().removeclass("is-active"); var step = $(this).attr("href"); $(".step-content[name='"+equipment+"']").not(step).css("display", "none"); $(step).fadetoggle(); $("#step-" + stepclass+"[name='"+equipment+"']").show(); // rotates the wheel $("#steps-menu[name='"+equipment+"']").removeclass(); var stepclass = step.charat(6); $("#steps-menu[name='"+equipment+"']").addclass("step-" + stepclass); currentnum=step.substr(rotatenum,1)-0+1; }); $("#steps-menu[name='wap'] a").tap(function(event) { // replaces main content event.preventdefault(); $(this).parent().addclass("is-active"); $(this).parent().siblings().removeclass("is-active"); var step = $(this).attr("href"); $(".step-content[name='"+equipment+"']").not(step).css("display", "none"); $(step).fadetoggle(); // rotates the wheel $("#steps-menu[name='"+equipment+"']").removeclass(); var stepclass = step.charat(6); $("#step-" + stepclass+"[name='"+equipment+"']").show(); $("#steps-menu[name='"+equipment+"']").addclass("step-" + stepclass); currentnum=step.substr(rotatenum,1)-0+1; }); //slideshow style interval var autoswap = setinterval( swap,5000); var currentnum = 2; //pause slideshow and reinstantiate on mouseout $("#read-more a, #steps-menu[name='"+equipment+"'] a").hover( function () { clearinterval(autoswap); }, function () { autoswap = setinterval( swap,5000); }); //swap images function function swap(action) { $("#bbp").fadeout(100); if(isnan(currentnum)) currentnum=1; console.log(currentnum); $("#steps-menu[name='"+equipment+"'] li a:eq("+ (currentnum-1) +")").parent().addclass("is-active"); $("#steps-menu[name='"+equipment+"'] li a:eq("+ (currentnum-1) +")").parent().siblings().removeclass("is-active"); console.log("当前"); var step = $("#steps-menu[name='"+equipment+"'] li a:eq("+ (currentnum-1) +")").attr("href"); console.log(step); $(".step-content[name='"+equipment+"']").not(step).css("display", "none"); $(step).fadetoggle(); // rotates the wheel $("#steps-menu[name='"+equipment+"']").removeclass(); var stepclass = step.charat(6); console.log(stepclass); $("#step-" + stepclass+"[name='"+equipment+"']").show(); $("#steps-menu[name='"+equipment+"']").addclass("step-" + stepclass); $("#bbp").fadein(800); currentnum+=1; if(currentnum==rotatenum+1) { currentnum=1; } } });