I want to change background image of a div, depending on what image is currently hovered by mouse. I want to create a gallery, so I have a list of images. I want to display the exact same url dynamically (hovered thumbnail) as hovered as a background of the main div (hero image).
<div id="background">
<ul>
<li><img src="image/1.jpg" alt="" /></li>
<li><img src="image/2.jpg" alt="" /></li>
<li><img src="image/3.jpg" alt="" /></li>
</ul>
</div>
At the beginning, the id="background"
has default background, which should be swaped to hovered image. When the image is unhovered, the image should back to the default one.
How can I do that using jquery the easiest way? It has to be the same url as the thumbnail, so it has to be dynamic, without additional url settings in jquery script file.