그림의 위쪽과 아래쪽을 전환합니다
3783 단어 JS 기술
<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>