My question involves a div containing five images, displayed in order as [1] [2] [3] [4] [5]. I am looking to create a JavaScript script that will automatically rearrange the images to display them as [2] [3] [4] [5] [1], then [3] [4] [5] [1] [2], and so on. So far, I have only been able to make the first image change. Is it possible for all the images to change using the current script I have? Thank you in advance. (Note: I do not know jQuery, I am a beginner in JavaScript.)
var i = 1;
var x = ["img/facebook.png", "img/linkedin.png", "img/mail.png", "img/twiter.png", "img/skype.png"];
var y = ["1", "2", "3", "4", "5"];
function slide(num) {
i = i + num;
if(i < 0) i = x.length - 1;
if (i > x.length - 1) i = 0
document.getElementById('image01').src = x[i];
document.getElementById('text01').innerHTML = i;
}
function autorun(){setInterval("slide(1)", 3000);}
body{margin: 0; padding: 0; color:#fdbf7d; font-family: courier new;}
.container{margin-left:auto; margin-right:auto; width:940px; padding:10px; background-color: yellow;}
#photo_gallery_container{background-color: brown;}
#photo_gallery{}
<!doctype html>
<html lang="en">
<head>
<title>Gallery</title>
<meta http-equiv="content" content="text/html"; charset=UTF-8>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body onload="autorun()">
<div class="container">
<div id="photo_gallery_container">
<div id="photo_gallery">
<center>
<img id="image01" src="img/facebook.png" width="100px" height="100px">
<img id="image02" src="img/linkedin.png" width="100px" height="100px">
<img id="image03" src="img/mail.png" width="100px" height="100px">
<img id="image04" src="img/twiter.png" width="100px" height="100px">
<img id="image05" src="img/skype.png" width="100px" height="100px">
<span id="text01">1</span>
<span id="text02">2</span>
<span id="text03">3</span>
<span id="text04">4</span>
<span id="text05">5</span>
</center>
</div>
<script type="text/javascript" src="myscript.js"></script>
</div>
</div>
</body>
</html>