JS切换图片
JS格式:
var i = 1;
function changeImg(){}
docunment.getElementById("img1").src="../../img/"+i+".jpg";
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>切换图片</title>
<style>
div{
border: 1px solid white;
width:500px ;
height: 350px;
margin: auto;
text-align: center;
}
</style>
<script>
var i=1;
function changeImg(){
i++;
if(i==4){
i=1;
}
document.getElementById("img1").src="../../img/"+i+".jpg";
}
</script>
</head>
<body>
<div>
<input type="button" value="下一张" onclick="changeImg()"/>
<img src="../../img/1.jpg" width="100%" height="100%" id="img1"/>
</div>
</body>
</html>