如何用JS控制表格背景色轮换第一秒显示红色,第二秒显示蓝色,第三秒显示红色,第四秒显示蓝色,以此类推...

解决方案 »

  1.   


    window.setInterval("document.getElementById('table1').style.backgroundColor='red'",1000)
      

  2.   

    <html> 
    <head> 
    <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> 
    <script> 
    var i =0 ;
    var a=['red','yellow','blue']
    window.setInterval("b()",1000)
    function b(){
    document.getElementById('altlayer').style.backgroundColor=a[i]
    i=(i+1)%3
    }
    </script> 
    </head> 
    <body> <a href='' id=altlayer  title='鼠标跟随' altbg='#3980f4' altcolor='#ffffff' altborder='#ffffff'>大字体 </a>
    </body> 
    </html>