so I have this html:
<div>
<div>
<a class="member-img" href="#" >
<img src="image.jpg" alt="member">
</a>
</div>
<div class="member-bar">
</div>
</div>
and i try to select "member-bar" when the user hovers "member-img"
$('.member-img').hover(function(){ $(this).closest(".member-bar").slideDown() });
but it doesn't seem to work, any help for this code ?
member-bar
would need to be a parent of member-img
in order for that to work. You need to first find the parent, then find member-bar
as a sibling:
$(".member-img").hover(function() {
$(this).parent().next(".member-bar").slideDown();
});
Here's a fiddle for the above code
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.