zoukankan      html  css  js  c++  java
  • JS练习:替换式图片自动轮播

    代码:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script>
            var index = 0;
    
            function changeImg() {
                // 获得要切换图片的那个元素
                var img = document.getElementById("img1");
                //计算出当前要切换到第几张图片
                var curIndex = index % 3 + 1;  //0,1,2
                img.src = "img/" + curIndex + ".jpg";  //1,2,3
                //每切换完,索引加1
                index = index + 1;
            }
    
            function init() {
                setInterval("changeImg()", 3000);
            }
        </script>
    </head>
    <body onload="init()">
        <img src="img/1.jpg" width="1920" id="img1"/>
    </body>
    </html>
  • 相关阅读:
    【POJ 2778】DNA Sequence
    【POJ 2923】Relocation
    codeforces 475D
    hdu4742
    hdu4741
    hdu5016
    poj3929
    Codeforces Round #267 (Div. 2)
    codeforces 455E
    hdu4073 Lights
  • 原文地址:https://www.cnblogs.com/believepd/p/10012543.html
Copyright © 2011-2022 走看看