如何让跑马灯效果一直循环不间断

解决方案 »

  1.   

    settimeout 不停的复制,比如:abcd,取abc,bcd赋值
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
       <style>
       .dd{width:30px;height:30px; background-color:blue;float:left;margin:5px;}
       </style> </head>
    <body>
        <form id="form1" runat="server">
       <a onclick="Start();">点击看看</a> 
           <div id="Div0" class="dd"></div>
           <div id="Div1" class="dd"></div>
           <div id="Div2" class="dd"></div>
           <div id="Div3" class="dd"></div>
           <div id="Div4" class="dd"> </div>
    <script>
    var Index=0;
    function Start()
    {
       for(var i=0;i<5;i++)
       {
          var obj=document.getElementById("Div"+i);  
          if(i==Index)  obj.style.background="red" ;
          else obj.style.background="blue";
       }
         Index=(Index+1)%5; 
         setTimeout("Start()",500);
    }
    </script>    </form>
    </body>
    </html>