• JS实现---图片轮播效果


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>JS幻灯代码</title>
        <script>
             
            function show(num) {
                var obj0=document.getElementById("image_0");
                switch (num){
                    case 1:
                        obj0.src="../image/2d77071d07b24c80ba9f5b8db7a364fb.jpg";
                        break;
                    case 2:
                        obj0.src="../image/00fba12e3275496a904141a1303fdcf3.jpg";
                        break;
                    case 3:
                        obj0.src="../image/3b8ec93770744ff4ad12e25ec4a200b1.jpg";
                        break;
                    case 4:
                        obj0.src="../image/1fbc738f98634c0f80f283e14455369c.jpg";
                        break;
                }
            }
    //定义定时器,每隔三秒就换图
            var index=1;
            function IMG() {
                setInterval(function () {
                    index++;
                    if (index>=4){
                        index=1;
                    }
                    show(index);
                },3000);
            }

        </script>
    </head>
    //需要注意的地方是:当页面加载完的时候就需要轮播图片 需要在body里边调用onload方法
    <body onload="IMG()">
    <div style=" 300px;height: 300px">
        <div style=" 100%;height: 100%">
            <img id="image_0" src="../image/2d77071d07b24c80ba9f5b8db7a364fb.jpg" />
            <div  style="position:absolute;left:150px;top:310px;">
                <a href="javascript:show(1)">1</a>&nbsp;
                <a href="javascript:show(2)">2</a>&nbsp;
                <a href="javascript:show(3)">3</a>&nbsp;
                <a href="javascript:show(4)">4</a>
            </div>
        </div>
        </div>
    </body>
    </html>

  • 相关阅读:
    关于Slowloris HTTP DoS
    [转]更新SDK失败后,出现无法找到SDK location的解决方法
    [吐槽文]一篇课设小结
    无聊时候打打字之百度地图 【更新中】
    git初学 多多指教
    无聊的时候打打字之寒假项目小记录
    机会来了,创业你准备好了吗?
    技术高速发展,IT人员路在何方?
    开发Web应用程序常用优化性能的技巧
    DataTable中存在空值 输出到EXCEL时格式变乱的解决方法【附代码】
  • 原文地址:https://www.cnblogs.com/Dionexin/p/5974320.html
Copyright © 2020-2023  润新知