When the user visits the web page and hovers over an album artwork, the title of the piece and the artist name appears. It leaves when the mouse leaves. I have achieved this with the following code: HTML:
<img id="pic1" src=" ">
<div class="info1">
<div class="name">artist</div>
<div class="songname">song title</div>
</div>
<img id="pic2" src=" ">
<div class="info2">
<div class="name">artist</div>
<div class="songname">song2</div>
</div>
JQuery
$(document).ready(function () {
$("img#pic1").hover(
function () {
$("div.info1").animate({
'opacity': 1
});
},
function () {
$("div.info1").animate({
'opacity': 0
});
});
});
$(document).ready(function () {
$("img#pic2").hover(
function () {
$("div.info2").animate({
'opacity': 1
});
},
function () {
$("div.info2").animate({
'opacity': 0
});
});
});
The problem is with the javascript; I have to manually add new parts when I add a new image and it takes up a lot of space. Is there a way to condense the code?
CSS: .info1, .info2 { opacity:0; }