JSFiddle - React, Tailwind, and code Playground
HTML
<div id="outerContainer">
<div id="frameA"><img src="http://placehold.it/300x300/cfc" /></div>
<div id="frameB"><img src="http://placehold.it/300x300/fcf" /></div>
<div id="frameC"><img src="http://placehold.it/300x300/ccf" /></div>
<div id="topImage">
<img src="http://placehold.it/100x100" class="topImage" />
</div><!--topImage-->
<div id="middleImage">
<img src="http://placehold.it/100x100" class="middleImage" />
</div><!--middleImage-->
<div id="bottomImage">
<img src="http://placehold.it/100x100" class="bottomImage" />
</div><!--bottomImage-->
</div><!--outerContainer-->
<input type="button" value="Generate" id="move" style="margin-top:20px;" />
<div id="message">
</div><!--message-->
CSS
#outerContainer{
background-color:#999;
height:300px;
width:300px;
background-image:url(images/Welcome.jpg);
position:relative;
}
#topImage{
height:100px;
}
#middleImage{
height:100px;
}
#bottomImage{
height:100px;
}
#frameA, #frameB, #frameC{
display:none;
position:absolute;
top:0;
left:0;
}
JavaScript
$(document).ready(function() {
//Creating array variables to store the file info
var obj = [{
"name": "First Image",
"urlTop": "http://placehold.it/300x100&text=FirstTop",
"urlMiddle": "http://placehold.it/300x100&text=FirstMiddle",
"urlBottom": "http://placehold.it/300x100&text=FirstBottom",
},
{
"name": "Second Image",
"urlTop": "http://placehold.it/300x100&text=SecondTop",
"urlMiddle": "http://placehold.it/300x100&text=SecondMiddle",
"urlBottom": "http://placehold.it/300x100&text=SecondBottom",
},
{
"name": "Third Image",
"urlTop": "http://placehold.it/300x100&text=ThirdTop",
"urlMiddle": "http://placehold.it/300x100&text=ThirdMiddle",
"urlBottom": "http://placehold.it/300x100&text=ThirdBottom",
}
] //Array
//Creating global variables
var randomNumA;
var randomNumB;
var randomNumC;
function generateRandomNumbers() {
//Generating a random number between 1 and the number of images
randomNumA = Math.ceil(Math.random() * (obj.length) - 1);
randomNumB = Math.ceil(Math.random() * (obj.length) - 1);
randomNumC = Math.ceil(Math.random() * (obj.length) - 1);
} //GenerateRandomNumbers
function generate() {
//Show the first frame
$("#frameA").fadeIn(2000);
//Once the first frame is done animating/
$("#frameA").promise().done(function() {
$("#frameA").fadeOut(2000); //Hide FrameA
$("#frameB").fadeIn(1000); //Show FrameB
//Once the frame be is shown
$("#frameB").promise().done(function() {
$("#frameB").fadeOut(300); //hide FrameB
$("#frameC").show(); //show frameC
generateRandomNumbers();
//Inserting all images/information to the appropriate div and giving it a unique name
...