<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript">
function init(){
setInterval("change()",2000);
}
var i=0;
function change(){
i++
document.getElementById("img1").src="../img/"+i+".jpg";
if(i==4){
i=0;
}
}
</script>
<body onload="init()">
<div >
<img src="../img/1.jpg" width="500px" id="img1" />
</div>
</body>
</html>