html中图片轮播怎么弄

2025-03-28 10:34:07
推荐回答(1个)
回答(1):


一、数字键控制代码:

    1
    2
  3
    4
    5
    6

     
 var nowIndex=1;
 var maxIndex=6;
 function show(index)
 {
 if(Number(index)){                                     
 clearTimeout(theTimer);
 nowIndex=index;
 }
 for(var i=1;i<(maxIndex+1);i++){
  if(i==nowIndex)
   {document.getElementById('pic'+nowIndex).style.display='';
   document.getElementById('I'+nowIndex).style.backgroundColor='red';}
  else
   {document.getElementById('pic'+i).style.display='none';
   document.getElementById('I'+i).style.backgroundColor='gray';}
  }{
  if(nowIndex==maxIndex)
   nowIndex=1;
  else
   nowIndex++;
  }
 theTimer=setTimeout('show()',3000);
 }
 
 

二、图片自动播放:




相关问答
最新问答