I have images in divs and I would like to have paragraphs to appear on top of them on mouseover, using jQuery. The paragraphs are initially hidden.
I've tried the following but can't make the paragraph to appear only when I mouseover one image, on top of that image only.
HTML:
<div id="photos">
<div class="test">
<img src="http://www.blset.com/img/300x200/biostat300200.jpg" />
<p class="desc">Test 1</p>
</div>
<div class="test">
<img src="http://www.blset.com/img/300x200/barometre1300200.jpg" />
<p class="desc">Test 2</p>
</div>
</div>
CSS:
#photos {position:relative;width:100%;height:100%;background:#ccc;}
#photos img {float:left;height:120px;}
#photos p {display:none; position:absolute;top:0;left:0;}
jQuery:
$(".test img").hover(function() {
$(".test p").fadeIn(200);
}, function () {
$(".test p").fadeOut(200);
});
jsFiddle: http://jsfiddle.net/m7zFb/13/