I was trying to figure out an assignment where I am supposed to use Javascript to hover over three different images, which shows the alt of the text in a separate box. I've got that part, but now I am completely lost when I try to revert to the original text. In my example for the second two images, I am hard coding the text I want, so it's the end result I want, only I want to call the text inside the div with the id="image" instead. The first function is working in my javascript. I want to add that I am completely new to Javascript, so I don't know all the reserved words yet.
function upDate(element){
document.getElementById('image').innerHTML = element.alt;
}
function unDo(preview){
document.getElementById('image').innerHTML = preview.alt;
}
/*Name this external file gallery.css*/
body{
margin: 2%;
border: 1px solid black;
background-color: #b3b3b3;
}
#image{
line-height:150px;
width: 575px;
height: 200px;
border:5px solid black;
margin:0 auto;
background-color: #8e68ff;
background-image: url('');
background-repeat: no-repeat;
color:#FFFFFF;
text-align: center;
background-size: 100%;
margin-bottom:25px;
font-size: 150%;
}
.preview{
width:10%;
margin-left:17%;
border: 10px solid black;
}
img{
width:95%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Photo Gallery</title>
<link rel="stylesheet" href="gallery.css">
<script src = "gallery.js"></script>
</head>
<body>
<div id = "image">
<p>Hover over an image below to display here.</p>
</div>
<img class = "preview" alt = "Styling with a Bandana" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon.jpg" onMouseOver = "upDate(this)" onMouseout = "unDo()">
<img class = "preview" alt = "With My Boy" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon2.JPG" onMouseOver = "upDate(this)" onMouseOut = "document.getElementById('image').innerHTML = 'Hover over an image below to display here.';">
<!--onMouseOut, onMouseLeave are both functional-->
<img class = "preview" alt = "Young Puppy" src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon3.jpg" onMouseOver = "upDate(this)" onMouseleave = "document.getElementById('image').innerHTML = 'Hover over an image below to display here.';">
</body>
</html>