开发者

How to show a hidden div on mouse over on a series of images

开发者 https://www.devze.com 2023-01-25 12:05 出处:网络
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.

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:

$(".peopl开发者_高级运维eImage").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();
});

jsFiddle example


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:

  • http://forum.jquery.com/topic/jquery-is-there-an-opposite-of-closet-selector
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号