I have to change the background of the div when I hover over the image, but somehow it's not detecting image though the URL is displayed in the console. I have no idea of jQuery. Thank you.
function upDate(previewPic) {
var divblock = document.getElementById('image');
var img = previewPic.src;
console.log(img);
divblock.style.backgroundImage = img;
divblock.innerHTML = previewPic.alt;
}
<div id="image">
Hover over an image below to display here.
</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="unDo()">
<img class="preview" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon3.jpg" alt="Young Puppy" onmouseover="upDate(this)" onmouseout="unDo()">
unDo()function in the example