<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div>
<button οnclick="nextImg()">下一张</button>
<br />
<img src="img/1.jpg" id="nImg" width="600px" height="400px" />
</div>
</body>
<script>
var i = 1;
function nextImg(){
i++;
var next = document.getElementById("nImg");
next.src = "img/pic"+i+".jpg";
if(i==3){
i=0;
}
}
</script>
</html>