当前位置:编程学习 > JS >>

js图片轮换

script type="text/javascript">
            var NowFrame = 1; //初始化显示第几张
            var MaxFrame = 3; //最大显示几张
            function show() {
                for (var i = 1; i < (MaxFrame + 1); i++) {
                    if (i == NowFrame)
                        document.getElementById('div' + NowFrame).style.display = ''; //当前图片显示
                    else
                        document.getElementById('div' + i).style.display = 'none'; //其他的图片隐藏
                }
                {
                    if (NowFrame == MaxFrame) //定义下一张显示的图片
                        NowFrame = 1;
                    else
                        NowFrame++;
                }
                theTimer = setTimeout('show()', 1000); //设置定时器,显示下一张显示的图片
            }
        </script>
</head>
<body  onload="show();">
    <form id="form1" runat="server">
        <div id="tupianlunhuan">
<img alt="" src="../images/5.png" style="display: none;" id="div1" border="0"/>
<img alt="" src="../images/1.jpg" style="display: none;" id="div2" border="0"/>
<img alt="" src="../images/3.png" style="display: none;" id="div3" border="0"/>
</div>       
    </form>
</body>
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,