• 轮播效果


    <style type="text/css">
            .img{display:none;}
            #dian{ 300px; height:20px; position:relative;  top:-30px; left:400px }
            .yuan{20px; height:20px; border:2px solid #0F6; border-radius:100px; float:left; margin-left:10px}
             
        </style>
        </head>
         
     
        <body>
            <div style="600px; height:300px;">
                <img style=" display:block;" class="img" src="file:///C|/Users/pc/Pictures/79077653_1.jpg"  width="600px" height="300"/>
                <img class="img" src="file:///C|/Users/pc/Pictures/2009040622372519.jpg" width="600px" height="300" />
                <img class="img" src="file:///C|/Users/pc/Pictures/373957f8f23c4023a2705e385861740a.jpg"  width="600px" height="300" />
                <img class="img" src="file:///C|/Users/pc/Pictures/140-16011Q52512.jpg"  width="600px" height="300"/>
                <img class="img" src="file:///C|/Users/pc/Pictures/140-150QZU313.jpg" width="600px" height="300" />
            </div>
             
             
            <div id="dian">
                <div bs="0" class="yuan" onclick="xianshi(this,'0')"></div>
                <div bs="1"  class="yuan" onclick="xianshi(this,'1')"></div>
                <div bs="2"  class="yuan" onclick="xianshi(this,'2')"></div>
                <div bs="3"  class="yuan" onclick="xianshi(this,'3')"></div>
                <div bs="4" class="yuan" onclick="xianshi(this,'4')"></div>
                 
            </div>
        </body>
     
     
        <script type="text/javascript">
        //图片索引
        var sy=0;
        //间隔时间
        window.setInterval("Huan()","4000");
            //掉一下换一个
            function Huan()
            {
            var img=document.getElementsByClassName("img");
            sy++;  //索引加1
            //判断到了最后一张
            if(sy>=img.length)
            {
                sy=0;
            }
     
            //让所有隐藏
            for(var i=0;i<img.length;i++)
            {
             img[i].style.display="none";  
            }
            //让下一张显示
            img[sy].style.display="block";
                 
            //换圆点的样式
            var yuan = document.getElementsByClassName("yuan");
                 
            for(var j=0;j<yuan.length;j++)
            {
                if(yuan[j].getAttribute("bs")==sy)
              {
               yuan[j].style.borderColor = "red";
              }
            else
               {
                  yuan[j].style.borderColor = "#0F6";
               }
                 }
            }
             
            function xianshi(t,s)
            {   
                sy=s;
                var img = document.getElementsByClassName("img");
                //让所有隐藏
                for(var i=0;i<img.length;i++)
                {
                    img[i].style.display="none";
                }
                //让下一张显示
                img[s].style.display="block";
                //改自身样式
                var yuan = document.getElementsByClassName("yuan");
                 
                for(var j=0;j<yuan.length;j++)
                {
                    yuan[j].style.borderColor="#0F6";
                }
                 
                t.style.borderColor="red";
            }
             
        </script>

  • 相关阅读:
    JS 循环遍历JSON数据 分类: JS技术 JS JQuery 2010-12-01 13:56 43646人阅读 评论(5) 收藏 举报 jsonc JSON数据如:{&quot;options&quot;:&quot;[{
    CLLocation的属性以及使用的解释
    单片机小白学步系列(十六) 单片机/计算机系统概述:模块化思想
    关于android中的单位(dp、sp)
    手动脱RLPack壳实战
    集成环信时遇到的问题file not found: libEaseMobClientSDK.a
    Cocos2dx 小技巧(九)现成的粒子特效
    设计模式
    2011 ACM-ICPC 成都赛区A题 Alice and Bob (博弈动规)
    hdu 2544 最短路(SPFA算法)
  • 原文地址:https://www.cnblogs.com/xieyulin/p/7070368.html
Copyright © 2020-2023  润新知