I have a series of images which have a description div hidden. I'm trying to show the description on a hover event. I can't see to get it to work. Here's the code.
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
Here's the jquery I'm working with:
$(".peopleImage").hover(function () {
var peopleInfo = $(this).closest('.peopleInfo');
peopleInfo.show();
});
Nothing seems to happen. Any suggestions would be appreciated!
Try this:
$(".peopleImage").hover(function () {
$('.peopleInfo', this).show();
}, function() {
$('.peopleInfo', this).hide();
});
try
(".peopleInfo").show()
Give sepearte id for each div and try to call show() with that id.
that will be better
Closest is getting the ancestors, you need to find children - look at this post:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.