function Gid(id){ return document.getElementById(id); } let lock = false; // 轮播图 let lis = document.getElementsByClassName("mainpage_imgs") lis[0].style.zIndex = '10'; lis[0].style.opacity = '1'; let points=document.getElementsByClassName("points"); let timer=null;//计时器 let index=0; let len = lis.length let preIndex = 0 function goNext(){ mainpageImgs_descChange(index); lis[preIndex].style.zIndex = '0'; lis[preIndex].style.opacity = '0'; lis[index].style.zIndex = '10'; lis[index].style.opacity = '1'; lis[index].style.transition ='opacity .5s'; for(let Choose = 0;Choose <=6 ; Choose++){ if (Choose !==index){ points[Choose].className = "points" ; } else points[Choose].className = "points active" ; } }//对目标元素显示 //按钮切换 Gid("change-right").addEventListener("click",function(){ preIndex = index; index=(index+1)%7; goNext(); }) Gid("change-left").addEventListener("click",function(){ preIndex = index; if(index==0) index=6; else index--; goNext(); }) //辅助切换 function points_change(thePrt){ preIndex = index; index=thePrt; goNext(); } for(let i=0;i