zoukankan      html  css  js  c++  java
  • JS对img进行操作

       <script type="text/javascript">
            var i = 1; var n;
            function showImg() {

                if (document.getElementById('img').getAttribute("src") == "images/1.jpg") {
                    document.getElementById('img').setAttribute("src","images/2.jpg");
                }
                else {
                     document.getElementById('img').setAttribute("src","images/1.jpg");
                }
            }

            function showImg1() {
                document.getElementById('img').setAttribute("src", "images/" + i + ".jpg"); i++;
                if (i > 10)
                {
                    i = 1;
                }
            }


            function show() {
              n=setInterval(showImg1, 500);
            }

            function show1() {
                clearInterval(n);
            }
        </script>

    </head>
    <body>
        <img id="img" alt="" src="images/1.jpg" width="200" height="200" />
        <input id="Button1" type="button" value="换图片" onclick="showImg()" />
        <input id="Button2" type="button" value="切图" onclick="showImg1()" />
        <input id="Button3" type="button" value="轮换" onclick="show()" />
            <input id="Button4" type="button" value="停止轮换" onclick="show1()" />

    </body>
    </html>

  • 相关阅读:
    ZOJ3113_John
    ZOJ3084_S-Nim
    CSUOJ1329——一行盒子_湖南省第九届大学生计算机程序设计竞赛
    CSUOJ 1141——第四届河南省程序设计大赛
    HDU4497——GCD and LCM
    H Hip To Be Square Day5——NWERC2012
    SPOJ3713——Primitive Root
    SPOJ4717——Grid Points in a Triangle
    SPOJ3899——Finding Fractions
    P2634 [国家集训队]聪聪可可(树形dp)
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3024895.html
Copyright © 2011-2022 走看看