<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script>
        var index = 0;  
        function changeImg() {
            var img = document.getElementById("img1");//获得切换图片的那个元素
            var curIndex = index%3 + 1;    //循环三张照片,可以看出当照片到头会自动再从第一张照片开始
            img.src = "img/横向美女0"+curIndex+".jpg";
            index = index + 1;
        }
        function init() {
            setInterval("changeImg()",2000);
        }
    </script>
</head>
<body onload="init()" >
    <img src="img/横向美女01.jpg" width="300px" height="180" id="img1" />
</body>
</html>

 


版权声明:本文为weixin_44718300原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_44718300/article/details/88723647