js实现简单的轮播效果

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript">
            function init(){
                setInterval("changelunbo()",1000);
            }
            var i = 1;
            function changelunbo(){
                i++;
                var imgE = document.getElementById("lunbo");
                imgE.src = "img/2."+i+".jpg";
                if(i == 4){
                    i = 0;
                }
            }
        </script>
    </head>
    <body onload="init()">
        <img src="img/2.1.jpg"/ id="lunbo">
    </body>
</html>

 

posted @ 2018-03-08 10:52  leerle  阅读(170)  评论(0编辑  收藏  举报