图片上一张与下一张切换

来源:互联网 发布:店铺陈列数据分析报告 编辑:程序博客网 时间:2024/05/03 01:29
<!DOCTYPE html><html lang="zh-cn"><head>    <meta charset="UTF-8">    <title>图片幻灯片切换</title></head><body>    <img src="images/001.jpg" id="imgid"><br/>    <input type="button" value="上一张" id="prev">    <input type="button" value="下一张" id="next"><script>    var adimg=['images/001.jpg','images/002.jpg','images/003.jpg'];    var numimg=0;    window.onload=function(){        document.getElementById('prev').onclick=prevProcess;        document.getElementById('next').onclick=nextProcess;    }    function prevProcess(){        if(numimg==0){            numimg=adimg.length;        }        numimg--;        document.getElementById('imgid').src=adimg[numimg];        return false;    }    function nextProcess(){        numimg++;        if(numimg==adimg.length){            numimg=0;        }        document.getElementById('imgid').src=adimg[numimg];        return false;    }</script></body></html>
0 0