• JS图片轮播


    <!DOCTYPE html>
    <html >

    <head>
        <meta charset="UTF-8">

        <title>Document</title>
        
    </head>

    <body>
        <img src="img/1.jpeg" id="flower">
        <br>
        <button id="prve">上</button>
        <button id="next">下</button>
        <script>
            // 获取id
              var flower=document.getElementById('flower');
              var nextbtn=document.getElementById('next');
              var prve=document.getElementById('prve');
              var minindex=1; maxindex=4;currentindex=minindex;
           
            //定义点击事件
          nextbtn.onclick=function(){
              currentindex++;
              if(currentindex==maxindex)
              {
                  currentindex=1;
              }
              flower.setAttribute('src','img/'+currentindex+'.jpeg')
          }

          prve.onclick=function(){
              currentindex--;
              if(currentindex==minindex)
              {
                  currentindex=4;
              }
              flower.setAttribute('src','img/'+currentindex+'.jpeg')
          }
        </script>
    </body>

    </html>
  • 相关阅读:
    UVa 1605
    UVa 120
    UVa 10384
    UVa 11694
    UVa 11846
    常用小函数
    【DP】:CF #319 (Div. 2) B. Modulo Sum
    类的无参方法
    类和对象
    七言
  • 原文地址:https://www.cnblogs.com/lxabner/p/12340702.html
Copyright © 2020-2023  润新知